Skip to content

Commit

Permalink
revert to 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizmo2 committed Dec 9, 2021
1 parent 556992f commit 05a705b
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 21 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ ZidooRC will eventually need to be released as a python library per HA requireme

Includes Media Browse support with favorites (although the latter is work-in-progress - currently hard-coded into media_player)

Dev is tested up to HA version 2021.10 and uses cover-flow.
1.2 is tested up to HA version 2021.10 and uses cover-flow.
Release 1.1 is tested from HA versions 2021.1 up to 2021.10, and requires manual integration.

![Media_Library](images/media_browser.png) ![Media_Player](images/media_player.png)
![Media_Library](images/media_browser.png) ![Media_Player](images/media_player.png) ![Media_Player](images/movie_playing.png)


## Installation
Expand All @@ -23,20 +23,20 @@ Release 1.1 is tested from HA versions 2021.1 up to 2021.10, and requires manual

### Manual Install

1. Copy zidoo folder to \config\custom_components (create folder if this is yuor first custom integration)
1. Copy `zidoo` folder to `\config\custom_components` (create folder if this is yuor first custom integration)
2. Restart HA

### Configuration

for latest version:

1. Add Zidoo Integration from the Configuraion-Integration menu
1. Add `Zidoo` Integration from the 'Configuraion-Integration' menu
2. Add the IP address of player
3. Enter the Password if you have authentication enabled

for version 1.1:

1. Edit your /config/configuration.yaml with
1. Edit your `/config/configuration.yaml` with

```
media_player:
Expand All @@ -46,16 +46,18 @@ media_player:
```
2. Restart HA

If you have issues connecting with the device, it may be an authorization issue.
> 1. Try opening the 'Control Center' app and retry.
> 2. Try turning off validation using the button in the app.
> If you have issues connecting with the device, it may be an authorization issue.
> 1. Try opening the 'Control Center' app and retry.
> 2. Try turning off validation using the button in the app.
## ToDo

- Testing on other devices
- WOL (does not work on Z9S due to hardware limitations - current code uses ethernet mac address)
- Authentication ( not sure if newer devices are more secure)
- Add Coverflow options for Shortcuts
- Authentication ( not sure if newer devices are more secure)
- Possible device specific options.
- Add Coverflow options for Shortcuts in Media Browse
- Add Discovery?



3 changes: 3 additions & 0 deletions custom_components/zidoo/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ async def async_step_user(self, user_input=None):
errors=errors,
)

async def async_step_import(self, user_input):
"""Handle import."""
return await self.async_step_user(user_input)

class ZidooOptionsFlowHandler(config_entries.OptionsFlow):
"""Handle a option flow for wiser hub."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/zidoo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"requirements": [],
"codeowners": ["@wizmo2"],
"iot_class": "local_polling",
"version": "1.2.1"
"version": "1.2.2"
}
5 changes: 5 additions & 0 deletions custom_components/zidoo/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ def media_seek(self, position):
"""Send media_seek command to media player."""
self._player.set_media_position(position, self._duration)

@property
def media_image_url(self):
"""Image url of current playing media."""
return self._player.generate_current_image_url()

async def async_browse_media(self, media_content_type=None, media_content_id=None):
"""Implement the websocket media browsing helper"""

Expand Down
59 changes: 50 additions & 9 deletions custom_components/zidoo/zidoorc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Sony Zidoo RC API
By Antonio Parraga Navarro
dedicated to Isabel
Zidoo Remote Control API
By Wizmo
Based on the Sony BraviaRC BY Antonio Parraga Navarro
"""
import logging
import collections
Expand Down Expand Up @@ -86,6 +86,9 @@

CONF_PORT = 9529

ZCONTENT_VIDEO = 'Video Player'
ZCONTENT_MUSIC = 'Music Player'
ZCONTENT_NONE = ''

class ZidooRC(object):
def __init__(self, host, psk=None, mac=None):
Expand All @@ -103,6 +106,9 @@ def __init__(self, host, psk=None, mac=None):
self._current_source = None
self._app_list = {}
self._power_status = False
self._video_id = -1
self._music_id = -1
self._last_video_path = None

def _jdata_build(self, method, params=None):
if params:
Expand Down Expand Up @@ -274,13 +280,19 @@ def get_playing_info(self):
if response is not None:
return_value = response
return_value["source"] = "video"
return return_value
if return_value.get("status") == True:
self._current_source = ZCONTENT_VIDEO
return return_value

response = self._get_music_playing_info()
if response is not None:
return_value = response
return_value["source"] = "music"
return return_value
if return_value["status"] == True:
self._current_source = ZCONTENT_MUSIC
return return_value

return return_value

def _get_video_playing_info(self):
"""Get information from built in video player."""
Expand All @@ -296,9 +308,22 @@ def _get_video_playing_info(self):
return_value["uri"] = result.get("path")
return_value["duration"] = result.get("duration")
return_value["position"] = result.get("currentPosition")
if return_value["status"] == True and return_value["uri"] != self._last_video_path:
self._last_video_path = return_value["uri"]
self._video_id = self._get_id_from_uri(self._last_video_path)
return return_value
return None

def _get_id_from_uri(self, uri):
response = self._req_json('ZidooPoster/v2/getAggregationOfFile?path={}'.format(uri))

if response: # and response.get("status") == 200:
result = response.get("video")
if result is not None:
return result.get("parentId")

return 0

def _get_music_playing_info(self):
"""Get information from the Music Player"""
return_value = {}
Expand All @@ -307,11 +332,12 @@ def _get_music_playing_info(self):
# _LOGGER.debug(json.dumps(response, indent=4))
if response is not None and response.get("status") == 200:
return_value["status"] = response.get("isPlay")
if response.get("music"):
result = response.get("music")
result = response.get("music")
if result is not None:
return_value["title"] = result.get("title")
return_value["artist"] = result.get("artist")
return_value["uri"] = result.get("uri")
self._music_id = result.get("databaseId")

result = response.get("state")
return_value["duration"] = result.get("duration")
Expand All @@ -320,15 +346,15 @@ def _get_music_playing_info(self):
return None

def _get_movie_playing_info(self):
"""Get information """
"""Get information."""
return_value = {}

response = self._req_json("ZidooControlCenter/getPlayStatus")

if response is not None and response.get("status") == 200:
if response.get("file"):
result = response.get("file")
return_value["status"] = result.get("status")
return_value["status"] = result.get("status") == 1
return_value["title"] = result.get("title")
return_value["uri"] = result.get("path")
return_value["duration"] = result.get("duration")
Expand Down Expand Up @@ -465,6 +491,21 @@ def generate_movie_image_url(self, movie_id, width=100, height=150):

return url

def generate_current_image_url(self, width=1080, height=720):
url = None

if self._current_source == ZCONTENT_VIDEO and self._video_id > 0:
url = "http://{}/ZidooPoster/getFile/getBackdrop?id={}&w={}&h={}".format(
self._host, self._video_id, width, height
)

if self._current_source == ZCONTENT_MUSIC and self._music_id > 0:
url = "http://{}/ZidooMusicControl/v2/getImage?id={}&musicType=1&type=4&target=16".format(
self._host, self._music_id
)

return url

def get_file_list(self, uri, file_type=0):
"""Return list of movies in hass format"""
response = self._req_json(
Expand Down
3 changes: 2 additions & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Feedback and PRs welcome.
## Features

- Control Zidoo devices as media players through HA
- Browse Movies, File System, and Share mounts through HA Media Browser
- Album art and movie backdrops
- Browse movies, file system, and share mounts through HA Media Browser

## Useful links

Expand Down

0 comments on commit 05a705b

Please sign in to comment.