I use your pyscript already.
Check this out: GitHub - chiahsing/nest_hub: Home Assistant pyscript for using Nest Hub as a dashboard. You can now set both mute_before_cast and restore_volume_level to true.
Your script looks good only i see some differences in your install notes and my HA.
'Create a nest_hub
folder under /config/pyscript/apps/
, and put __init__.py
in it. Then, in pyscript
‘s config.yaml
, add the following section:’
The ‘/config/pyscript/apps/’ is not a correct location after a new fresh install of pyscripts.
With HACS it would be: YOUR_HASS_CONFIG_DIRECTORY/custom_components
Also i dont see config.yaml in that folder.
I updated the doc about the config.yaml. I was talking about this. It actually can be whatever file you want. I followed the recommendation of pyscript to put it under the pyscript directory with
pyscript: !include pyscript/config.yaml
in my HA configuration.yaml. Obviously you can name it whatever you want.
I’ve got it setup but I must have an error since it’s not working.
this is my code:
apps:
nest_hub:
dashboard_url: 'http://192.168.0.108:8123/lovelace/default_view?wp_enabled=true'
off_duration: 0
entities:
- entity_id: media_player.nesthubde64
enable_switch: input_boolean.cast_to_hub
off_duration: 10
idle_duration: 180
paused_duration: 360
boot_delay: 20
mute_before_recast: true
restore_volume_level: true
recast_on_start: true
I want it to start automatically based on the input boolean, is that supposed to work?
Also previously I did not have anything added to my configuration.yaml for pyscript. All I had to do was drop your one file in the pyscript folder…
Great idea, although I try to keep as much as possible within HA myself so I’m going to have a go at writing this up as a HA Script/Automation and see how far I get - thanks for the ideas in the README though. I’ve found the built in cast integration to be a bit more reliable than DashCast personally but maybe I’m just lucky!
However the main thing that has led me to avoiding one of these hubs for a bedside dashboard is the noise made when setting volume… Even if you mute the initial cast tone, you’re going to get a “boop” sound when setting the volume to anything, not ideal when sleeping. We use ours as an alarm/sleep noises so wouldn’t want it muted overnight. I suppose best approach here is if it drops overnight don’t recast until the alarm goes off in the morning.
The script should go into /config/pyscript/apps/nest_hub/
Yeah, as I said in the README, it works best if the device is used as a dedicated dashboard and you don’t mind keeping it muted all the time.
OK it working on boot now. But it doesn’t stop on the switch and it doesn’t recast after the switch is turned back on.
I decided to go back to your first script with the removed audio change. It seems to be rock solid. The new script throws the hub into a fit of rebooting or something.
so please a little bit more help.
I have made is so far… installed pyscript and setup true UI.
Then i read about set up config.yaml for pyscript, so i did that… but there i no template for that to see to set up.
Do you have this in your HA configuration.yaml?
pyscript: !include pyscript/config.yaml
yes i have that in mij configuration.yaml
also i have now in my pyscript/config.yaml
apps:
apps/nest_hub/__init__.py
and then in my __init file
_DASHBOARD_URL = 'http://1xxx71:8123/dashboard-tablet/default_view'
# The part after 'media_player.'
_NEST_HUBS = ['nest_hub'] #for more use , 'nest_hub_study'
def nest_hub_trigger_factory(nest_hub):
entity_id = f'media_player.{nest_hub}'
avail_state = f'pyscript.{nest_hub}_availability'
state.persist(avail_state, default_value='1')
@state_trigger(f'{entity_id} == "off"', state_check_now=True)
def recast_nest_hub():
if state.get(avail_state) == '0':
log.info(f'{entity_id} was unavailable. Wait for 20 secs')
state.set(avail_state, '1')
task.sleep(20)
log.info(f'Recast {entity_id}')
media_player.volume_set(entity_id=entity_id, volume_level=0)
dash_cast.load_url(entity_id=entity_id,
url=_DASHBOARD_URL, force=True)
@state_trigger(f'{entity_id} == "unavailable"', state_check_now=True)
def nest_hub_is_unavailable():
log.info(f'{entity_id} is unavailable')
state.set(avail_state, '0')
return recast_nest_hub, nest_hub_is_unavailable
_triggers = [nest_hub_trigger_factory(nh) for nh in _NEST_HUBS]```
To verify that your pyscript is set up correctly, you can enable logs for pyscript by using the config in this Readme file understanding · Issue #1 · chiahsing/nest_hub · GitHub
i can see the log message you showt me
2023-02-11 18:54:13.680 INFO (MainThread) [custom_components.pyscript.global_ctx] Reloaded /config/pyscript/apps/nest_hub/__init__.py```
and offcoure i did change the init_py file.. but nothing happend on my nest hub.
I’m using your new script now, however it always stops casting eventually.
Wish there was a reliable way to make this work, we are so close. It seems to work fine for a few hours, but then tanks.
EDIT: Also muting the notification eventually makes all sound dissappear.
Hi, i succesfully confired all staff but i stop on running the script. On google nest just showing the logo Dashcast and after 2 seconds turn off. I check the logs, settings but i dint found any mistake. Could somebody help me please?
alias: Cast Dashboard
sequence:
- choose:
- conditions:
- condition: template
value_template: >-
{{ state_attr('media_player.living_room_display', 'app_name') !=
'DashCast' }}
sequence:
- service: media_player.volume_set
data:
volume_level: 0
target:
entity_id: media_player.living_room_display
- service: dash_cast.load_url
data:
entity_id: media_player.living_room_display
url: http://homeassistant.local:8123/dashboard-fvi/0
force: true
mode: single
icon: mdi:script
homeassistant:
auth_providers:
- type: trusted_networks
trusted_networks:
- 192.168.88.238 # my Google Nest Hub IP
trusted_users:
192.168.88.238: abcdefghchijklmnop
allow_bypass_login: true
- type: homeassistant
I check the pyscript but the documentation, github info are not clear. Somewhere is written pyscript to configuration.yaml. But we can not put the duplicated keys like two time pyscript. So could somebody simple writen what is necessary to run pyscript on google nest? I created pyscript folder, init.py etc. but nothing happend even after restart - how to cas to google nest? It is not running automatically . this is totaly unclear…
I have this in configuration.yaml
pyscript:
allow_all_imports: true
hass_is_global: true
apps:
nest_hub:
this in pyscript apps nest_hub in file named init.py
_DASHBOARD_URL = 'http://homeassistant.local:8123/dashboard-fvi/0'
# The part after 'media_player.'
_NEST_HUBS = ['living_room_display']
def nest_hub_trigger_factory(nest_hub):
entity_id = f'media_player.{nest_hub}'
avail_state = f'pyscript.{nest_hub}_availability'
state.persist(avail_state, default_value='1')
@state_trigger(f'{entity_id} == "off"', state_check_now=True)
def recast_nest_hub():
if state.get(avail_state) == '0':
log.info(f'{entity_id} was unavailable. Wait for 20 secs')
state.set(avail_state, '1')
task.sleep(20)
log.info(f'Recast {entity_id}')
media_player.volume_set(entity_id=entity_id, volume_level=0)
dash_cast.load_url(entity_id=entity_id,
url=_DASHBOARD_URL, force=True)
@state_trigger(f'{entity_id} == "unavailable"', state_check_now=True)
def nest_hub_is_unavailable():
log.info(f'{entity_id} is unavailable')
state.set(avail_state, '0')
return recast_nest_hub, nest_hub_is_unavailable
_triggers = [nest_hub_trigger_factory(nh) for nh in _NEST_HUBS]`
but nothing happend, no log error, nothing showing nowhere …
Hi how you make pyscript running ? Could you recommend how to?