Jump to content

Home Assistant 0.104


jriker1

Recommended Posts

WilhelmStroker

at the time (probably about a year ago), the HA integration wasn't working very well for me and was very slow so once the plugin came out I switched to that as the developer was able to add functionality very quickly.

Link to comment
Share on other sites

MRobi

For any HA users using node red, here's a few basic ones I made for controlling lights based on play states. In the living room sets light level after sunset based on play, pause, stop. In the bedroom turns lights off on play after 10pm.

 

5eb152b743c55_Capture.png

[{"id":"3e3c1d74.5330c2","type":"tab","label":"Emby","disabled":false,"info":""},{"id":"67ea21a1.7d72a","type":"api-call-service","z":"3e3c1d74.5330c2","name":"Dim to 60%","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_bulbs","data":"{\"brightness_pct\": 60}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":750,"y":160,"wires":[["7f7f9a4.90d5564"]]},{"id":"bd377234.4db91","type":"server-state-changed","z":"3e3c1d74.5330c2","name":"Living Room Emby","server":"94fdcfdf.a00b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.emby_living_room_tv","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":90,"y":220,"wires":[["ce7e2c4d.7b21e"]]},{"id":"d88e75c1.87c458","type":"switch","z":"3e3c1d74.5330c2","name":"Play State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"playing","vt":"str"},{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"idle","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":410,"y":220,"wires":[["c3cd0477.5128b8"],["3e697c93.9840c4"],["b411c422.413a98"]]},{"id":"c3cd0477.5128b8","type":"api-current-state","z":"3e3c1d74.5330c2","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_bulbs","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":160,"wires":[["67ea21a1.7d72a"],[]]},{"id":"3b4b04ef.7763ec","type":"api-call-service","z":"3e3c1d74.5330c2","name":"Dim to 80%","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_bulbs","data":"{\"brightness_pct\": 80}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":750,"y":220,"wires":[["a669e9e3.9cc388"]]},{"id":"d0f9d5c5.b863c8","type":"api-call-service","z":"3e3c1d74.5330c2","name":"Dim to 100%","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_bulbs","data":"{\"brightness_pct\": 100}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":750,"y":280,"wires":[["db49ef37.090ff"]]},{"id":"7f7f9a4.90d5564","type":"debug","z":"3e3c1d74.5330c2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":910,"y":160,"wires":[]},{"id":"a669e9e3.9cc388","type":"debug","z":"3e3c1d74.5330c2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":910,"y":220,"wires":[]},{"id":"db49ef37.090ff","type":"debug","z":"3e3c1d74.5330c2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":910,"y":280,"wires":[]},{"id":"3e697c93.9840c4","type":"api-current-state","z":"3e3c1d74.5330c2","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_bulbs","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":220,"wires":[["3b4b04ef.7763ec"],[]]},{"id":"b411c422.413a98","type":"api-current-state","z":"3e3c1d74.5330c2","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_bulbs","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":280,"wires":[["d0f9d5c5.b863c8"],[]]},{"id":"ce7e2c4d.7b21e","type":"time-range-switch","z":"3e3c1d74.5330c2","name":"Sunset","lat":"46.222715","lon":"-64.500891","startTime":"sunset","endTime":"sunrise","startOffset":"-30","endOffset":"+30","x":260,"y":220,"wires":[["d88e75c1.87c458"],[]]},{"id":"c7d117d1.22bde8","type":"server-state-changed","z":"3e3c1d74.5330c2","name":"Bedroom Emby","server":"94fdcfdf.a00b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.emby_bedroom","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":80,"y":420,"wires":[["3d702cd1.96cfd4"]]},{"id":"3d702cd1.96cfd4","type":"time-range-switch","z":"3e3c1d74.5330c2","name":"After 10pm?","lat":"46.222715","lon":"-64.500891","startTime":"22:00","endTime":"sunrise","startOffset":0,"endOffset":"+30","x":254,"y":420,"wires":[["20a4b47d.6f13fc"],[]]},{"id":"20a4b47d.6f13fc","type":"switch","z":"3e3c1d74.5330c2","name":"Play State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"playing","vt":"str"},{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"idle","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":410,"y":420,"wires":[["e8e5602b.895e4"],[],[]]},{"id":"e8e5602b.895e4","type":"api-current-state","z":"3e3c1d74.5330c2","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.master_bedroom_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":400,"wires":[["843eca3c.ac31b8"],[]]},{"id":"843eca3c.ac31b8","type":"api-call-service","z":"3e3c1d74.5330c2","name":"Turn Off","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.master_bedroom_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":740,"y":400,"wires":[["d366beb2.1b1c9"]]},{"id":"d366beb2.1b1c9","type":"debug","z":"3e3c1d74.5330c2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":900,"y":400,"wires":[]},{"id":"94fdcfdf.a00b","type":"server","z":"","name":"Home Assistant","addon":true}]
Edited by MRobi
  • Like 1
Link to comment
Share on other sites

Bambu Utila

Is there any update on a Home Assistant plugin for Emby?

 

I started playing around with HA about 2-3 days ago and really like it

I managed to get lights to turn on/ off set scenes when Emby starts/pauses/stops, but at the moment this is for all media, not just for Movies.

Looking into how to do that seems a lot harder, so i was hoping there might be some update on a HA plugin that does the heavy lifting for me/us :)

 

To get around this limitation at the moment what i did is use the Philips hue plugin in Emby to set when i want them to turn on.

In HA my triggers depend on hue lights turning on to do the rest.

Since the Philips Hue plugin doesn't allow you to turn lights off at the end of the movie i added a trigger for that too using the state of the mediaplayer, like most of you ar edoing

Link to comment
Share on other sites

Bambu Utila

 

I made an automation to control my lights when playing media

##########################
## Entertainment Cinema
##########################
- alias: "Film cinema afspelen"
  trigger:
  - entity_id: media_player.emby_kodi_cinema
    platform: state
    from: idle
    to: playing
  condition: []
  action:
  - service: light.turn_off
    data:
      entity_id: 
        - light.cinema
        
- alias: "Film cinema gepauzeerd"
  trigger:
  - entity_id: media_player.emby_kodi_cinema
    platform: state
    from: playing
    to: paused
  condition: []
  action:
  - service: scene.turn_on
    entity_id: scene.movie_cinema_dim
    
- alias: "Film cinema gestopt"
  trigger:
  - entity_id: media_player.emby_kodi_cinema
    platform: state
    from: playing
    to: idle
  condition: []
  action:
  - service: scene.turn_on
    entity_id: scene.movie_cinema_normal

Depending on how you have KODI set up it might be a good idea to include a trigger for going from paused to idle to set your scene back to normal

When i get my menu up in KODI it pauses the movie. At that point your playing to idle will not trigger.

At least that's what i ran into :)

Link to comment
Share on other sites

Bambu Utila

Yeah thats the basic one.

Why do you prefer adding it to emby (with hue plugin) than straight with Home Assistant.

Most solid is HA i think

I use a combination because i'm not smart enough to figure out how to only change the scene when i'm playing a movie, not for all media.

If you want it to set the scenes for anything you play i would probably also do it all in HA, only one place to look for changes that way.

Link to comment
Share on other sites

MRobi

Is there any update on a Home Assistant plugin for Emby?

 

I started playing around with HA about 2-3 days ago and really like it

I managed to get lights to turn on/ off set scenes when Emby starts/pauses/stops, but at the moment this is for all media, not just for Movies.

 

The media type is in the payload. If you use node-red, you can use my flow from above and put in a switch using a property of data.new_state.attributes.media_content_type (UPDATED) and filter automations based on type using that switch. So you can have it do 1 thing for movies, another for tvshows, etc..

 

Here's a look at the payload

 

5eb60d56df7f2_Capture.png

Edited by MRobi
  • Like 1
Link to comment
Share on other sites

Bambu Utila

The media type is in the payload. If you use node-red, you can use my flow from above and put in a switch using a property of msg.data.old_state.attributes.media_content_type and filter automations based on type using that switch. So you can have it do 1 thing for movies, another for tvshows, etc..

 

Here's a look at the payload

 

5eb60d56df7f2_Capture.png

 

Thanks for that, is it easy to learn node-red? I find the learning curve for HA already pretty steep.

I'm still looking for basic tutorials to get me started.

I'll have a look at node-red and see how that can help me out.

Link to comment
Share on other sites

Bambu Utila

The media type is in the payload. If you use node-red, you can use my flow from above and put in a switch using a property of msg.data.old_state.attributes.media_content_type and filter automations based on type using that switch. So you can have it do 1 thing for movies, another for tvshows, etc..

 

Here's a look at the payload

 

 

 

I installed node-red and imported your flow.

After some tinkering around i have it set up like you do but it uses a hue service to call my scenes.

And it all works, so that's a great first step.

 

Once in add an extra switch on the msg.data.old_data.attributes.media_content_type property I run into some problems though. It seems like the status of your play state gets read as idle instead of playing. So when you press play it thinks the play state is idle and nothing happens to your lights. it's only after you press pause that everything seems to go back to normal, the pause scene is activated and when you press play or stop the right behavior also occurs.

 

I placed the extra switch between the timer and the play state switch. That seems like the most logical place, right?

 

So it's only on start up that it goes wrong, any idea what that could be?

Edited by Bambu Utila
Link to comment
Share on other sites

MRobi

I placed the extra switch between the timer and the play state switch. That seems like the most logical place, right?

 

So it's only on start up that it goes wrong, any idea what that could be?

Sounds to me like you're testing too early after deploying your node. When you first hit deploy you'll see underneath the event state it will say "disconnected". Give it 10-15s to subscribe to the event, it will show connected again, and then try. 

 

Whether you put it before or after your play state switch would be a matter of preference for which route you want to take when building your automation.

Edited by MRobi
Link to comment
Share on other sites

Bambu Utila

Sounds to me like you're testing too early after deploying your node. When you first hit deploy you'll see underneath the event state it will say "disconnected". Give it 10-15s to subscribe to the event, it will show connected again, and then try. 

 

Whether you put it before or after your play state switch would be a matter of preference for which route you want to take when building your automation.

 

That doesn't seem to be the problem. i wait until it says connected. 

When i start the movie and go check the Flow, it clearly says playing under the Emby entity. Yet nothing happens.

It only kicks in after i press pause the first time.

It seems like the first time it reads an old state. from then on it goes well.

Link to comment
Share on other sites

MRobi

That doesn't seem to be the problem. i wait until it says connected. 

When i start the movie and go check the Flow, it clearly says playing under the Emby entity. Yet nothing happens.

It only kicks in after i press pause the first time.

It seems like the first time it reads an old state. from then on it goes well.

Ya that shouldn't happen. And it doesn't do that when you copied my flow? You may have something off in the switch you put in. You should post up your flow

Link to comment
Share on other sites

Bambu Utila

Ya that shouldn't happen. And it doesn't do that when you copied my flow? You may have something off in the switch you put in. You should post up your flow

[{"id":"2a3a369e.4cc9fa","type":"tab","label":"Emby","disabled":false,"info":""},{"id":"a57a53b4.5dafd","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"Set Scene Movies","server":"585c13de.6f939c","version":1,"debugenabled":true,"service_domain":"hue","service":"hue_activate_scene","entityId":"","data":"{\"group_name\":\"Living room\",\"scene_name\":\"Movies\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1170,"y":80,"wires":[["6e07c15e.2e4f1"]]},{"id":"9b8438d7.e43548","type":"server-state-changed","z":"2a3a369e.4cc9fa","name":"Living Room Emby Kodi","server":"585c13de.6f939c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.emby_kodi_mediacenter","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":100,"y":240,"wires":[["1ac9fbfe.186004"]]},{"id":"1121f460.addecc","type":"switch","z":"2a3a369e.4cc9fa","name":"Play State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"playing","vt":"str"},{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"idle","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":850,"y":240,"wires":[["a57a53b4.5dafd","9d72653.6c0df98","78423e61.e44ff"],["fda770a9.bcf09","78423e61.e44ff"],["3d6efaf1.e6faf6","5b109c87.bd6754","78423e61.e44ff"]]},{"id":"fda770a9.bcf09","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"Set Scene Movies Paused","server":"585c13de.6f939c","version":1,"debugenabled":false,"service_domain":"hue","service":"hue_activate_scene","entityId":"","data":"{\"group_name\":\"Living room\",\"scene_name\":\"Movies Paused\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1200,"y":240,"wires":[["f8117556.f8bd28"]]},{"id":"3d6efaf1.e6faf6","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"Turn off Entertainment area","server":"585c13de.6f939c","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"group.entertainment_area, group.livingroom_fanlights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1200,"y":340,"wires":[["836f122b.706b1"]]},{"id":"6e07c15e.2e4f1","type":"debug","z":"2a3a369e.4cc9fa","name":"Play Node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1450,"y":120,"wires":[]},{"id":"f8117556.f8bd28","type":"debug","z":"2a3a369e.4cc9fa","name":"Pause Node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1450,"y":240,"wires":[]},{"id":"836f122b.706b1","type":"debug","z":"2a3a369e.4cc9fa","name":"Idle Node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1440,"y":360,"wires":[]},{"id":"1ac9fbfe.186004","type":"time-range-switch","z":"2a3a369e.4cc9fa","name":"After 7pm?","lat":"46.222715","lon":"-64.500891","startTime":"10:00","endTime":"04:00","startOffset":0,"endOffset":"","x":350,"y":240,"wires":[["8d33225.0ad09e"],[]]},{"id":"9d72653.6c0df98","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"","server":"585c13de.6f939c","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.living_room_spots","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1170,"y":140,"wires":[["6e07c15e.2e4f1"]]},{"id":"8d33225.0ad09e","type":"switch","z":"2a3a369e.4cc9fa","name":"Movies or TV Show?","property":"data.old_state.attributes.media_content_type","propertyType":"msg","rules":[{"t":"eq","v":"movie","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":240,"wires":[["1121f460.addecc"]]},{"id":"5b109c87.bd6754","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"Turn on Living Room Spots","server":"585c13de.6f939c","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.living_room_spots","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1200,"y":420,"wires":[["836f122b.706b1"]]},{"id":"78423e61.e44ff","type":"debug","z":"2a3a369e.4cc9fa","name":"Play State","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":910,"y":420,"wires":[]},{"id":"585c13de.6f939c","type":"server","z":"","name":"Home Assistant","addon":true}]

This should be it i believe. Thanks for helping out!

Link to comment
Share on other sites

MRobi
[{"id":"2a3a369e.4cc9fa","type":"tab","label":"Emby","disabled":false,"info":""},{"id":"a57a53b4.5dafd","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"Set Scene Movies","server":"585c13de.6f939c","version":1,"debugenabled":true,"service_domain":"hue","service":"hue_activate_scene","entityId":"","data":"{\"group_name\":\"Living room\",\"scene_name\":\"Movies\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1170,"y":80,"wires":[["6e07c15e.2e4f1"]]},{"id":"9b8438d7.e43548","type":"server-state-changed","z":"2a3a369e.4cc9fa","name":"Living Room Emby Kodi","server":"585c13de.6f939c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.emby_kodi_mediacenter","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":100,"y":240,"wires":[["1ac9fbfe.186004"]]},{"id":"1121f460.addecc","type":"switch","z":"2a3a369e.4cc9fa","name":"Play State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"playing","vt":"str"},{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"idle","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":850,"y":240,"wires":[["a57a53b4.5dafd","9d72653.6c0df98","78423e61.e44ff"],["fda770a9.bcf09","78423e61.e44ff"],["3d6efaf1.e6faf6","5b109c87.bd6754","78423e61.e44ff"]]},{"id":"fda770a9.bcf09","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"Set Scene Movies Paused","server":"585c13de.6f939c","version":1,"debugenabled":false,"service_domain":"hue","service":"hue_activate_scene","entityId":"","data":"{\"group_name\":\"Living room\",\"scene_name\":\"Movies Paused\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1200,"y":240,"wires":[["f8117556.f8bd28"]]},{"id":"3d6efaf1.e6faf6","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"Turn off Entertainment area","server":"585c13de.6f939c","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"group.entertainment_area, group.livingroom_fanlights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1200,"y":340,"wires":[["836f122b.706b1"]]},{"id":"6e07c15e.2e4f1","type":"debug","z":"2a3a369e.4cc9fa","name":"Play Node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1450,"y":120,"wires":[]},{"id":"f8117556.f8bd28","type":"debug","z":"2a3a369e.4cc9fa","name":"Pause Node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1450,"y":240,"wires":[]},{"id":"836f122b.706b1","type":"debug","z":"2a3a369e.4cc9fa","name":"Idle Node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1440,"y":360,"wires":[]},{"id":"1ac9fbfe.186004","type":"time-range-switch","z":"2a3a369e.4cc9fa","name":"After 7pm?","lat":"46.222715","lon":"-64.500891","startTime":"10:00","endTime":"04:00","startOffset":0,"endOffset":"","x":350,"y":240,"wires":[["8d33225.0ad09e"],[]]},{"id":"9d72653.6c0df98","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"","server":"585c13de.6f939c","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.living_room_spots","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1170,"y":140,"wires":[["6e07c15e.2e4f1"]]},{"id":"8d33225.0ad09e","type":"switch","z":"2a3a369e.4cc9fa","name":"Movies or TV Show?","property":"data.old_state.attributes.media_content_type","propertyType":"msg","rules":[{"t":"eq","v":"movie","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":240,"wires":[["1121f460.addecc"]]},{"id":"5b109c87.bd6754","type":"api-call-service","z":"2a3a369e.4cc9fa","name":"Turn on Living Room Spots","server":"585c13de.6f939c","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.living_room_spots","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1200,"y":420,"wires":[["836f122b.706b1"]]},{"id":"78423e61.e44ff","type":"debug","z":"2a3a369e.4cc9fa","name":"Play State","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":910,"y":420,"wires":[]},{"id":"585c13de.6f939c","type":"server","z":"","name":"Home Assistant","addon":true}]

This should be it i believe. Thanks for helping out!

 

This one is on me. I gave you the wrong path in the payload. Looks like the payload sends the old state and the new state. So if your old state media type was a tv show, music, or nothing it wouldn't make it through the first switch.

 

Try this one instead. Change the property on your switch to this:

data.new_state.attributes.media_content_type

Edited by MRobi
Link to comment
Share on other sites

Bambu Utila

This one is on me. I gave you the wrong path in the payload. Looks like the payload sends the old state and the new state. So if your old state media type was a tv show, music, or nothing it wouldn't make it through the first switch.

 

Try this one instead. Change the property on your switch to this:

data.new_state.attributes.media_content_type

 

I changed it, and it solved the problem for the start, but now it doesn't register the going to idle part.

it does what it is expected to do when you play and pause, but when you stop it stays in paused mode.

 

It seems like the playstate reads the msg.payload from the previous switch in stead of the msg.payload from the original entity. I think that's where it goes wrong. Does that make sense? Also any idea on how to fix this?

Link to comment
Share on other sites

MRobi

I changed it, and it solved the problem for the start, but now it doesn't register the going to idle part.

it does what it is expected to do when you play and pause, but when you stop it stays in paused mode.

 

It seems like the playstate reads the msg.payload from the previous switch in stead of the msg.payload from the original entity. I think that's where it goes wrong. Does that make sense? Also any idea on how to fix this?

Thinking through it, the media type switch will route the payload based on the type of media being played (ie: movie, tvshow, etc). At idle, or stop, there is no media being played so the payload would stop at that switch. So you'd have to break your idle switch outside of the media type OR move the media type further down the chain. I would do the later. I'll take a quick crack at it now and I'll post it up.

Link to comment
Share on other sites

MRobi

This should do it.

 

5eb7ef0294c0e_Capture.png

[{"id":"70ad660a.1affd8","type":"tab","label":"Emby","disabled":false,"info":""},{"id":"1cd68751.669e69","type":"server-state-changed","z":"70ad660a.1affd8","name":"Living Room Emby","server":"94fdcfdf.a00b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.emby_living_room_tv","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":55,"y":86,"wires":[["a753b9f6.0981f8"]]},{"id":"45985604.63f4c8","type":"switch","z":"70ad660a.1affd8","name":"Play State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"playing","vt":"str"},{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"idle","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":375,"y":86,"wires":[["8df30326.c3499"],["b9882bdc.214d08"],["f336d2a8.6c16e"]]},{"id":"1b7db285.4b210d","type":"api-call-service","z":"70ad660a.1affd8","name":"Dim to 80%","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_bulbs","data":"{\"brightness_pct\": 80}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":895,"y":86,"wires":[[]]},{"id":"9a408af.79e2a78","type":"api-call-service","z":"70ad660a.1affd8","name":"Dim to 100%","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_bulbs","data":"{\"brightness_pct\": 100}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":730,"y":146,"wires":[[]]},{"id":"aebd2f79.1a7b4","type":"api-current-state","z":"70ad660a.1affd8","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_bulbs","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":729,"y":86,"wires":[["1b7db285.4b210d"],[]]},{"id":"f336d2a8.6c16e","type":"api-current-state","z":"70ad660a.1affd8","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_bulbs","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":555,"y":146,"wires":[["9a408af.79e2a78"],[]]},{"id":"a753b9f6.0981f8","type":"time-range-switch","z":"70ad660a.1affd8","name":"Sunset","lat":"46.222715","lon":"-64.500891","startTime":"sunset","endTime":"sunrise","startOffset":"-30","endOffset":"+30","x":225,"y":86,"wires":[["45985604.63f4c8"],[]]},{"id":"b9882bdc.214d08","type":"switch","z":"70ad660a.1affd8","name":"Media Type","property":"data.new_state.attributes.media_content_type","propertyType":"msg","rules":[{"t":"eq","v":"movie","vt":"str"},{"t":"eq","v":"tvshow","vt":"str"},{"t":"eq","v":"music","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":555,"y":86,"wires":[["aebd2f79.1a7b4"],["aebd2f79.1a7b4"],[]]},{"id":"8df30326.c3499","type":"switch","z":"70ad660a.1affd8","name":"Media Type","property":"data.new_state.attributes.media_content_type","propertyType":"msg","rules":[{"t":"eq","v":"movie","vt":"str"},{"t":"eq","v":"tvshow","vt":"str"},{"t":"eq","v":"music","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":555,"y":26,"wires":[["71095e8b.73cf7"],["71095e8b.73cf7"],[]]},{"id":"71095e8b.73cf7","type":"api-current-state","z":"70ad660a.1affd8","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_bulbs","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":730,"y":26,"wires":[["5f634947.d371c8"],[]]},{"id":"5f634947.d371c8","type":"api-call-service","z":"70ad660a.1affd8","name":"Dim to 60%","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_bulbs","data":"{\"brightness_pct\": 60}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":895,"y":26,"wires":[[]]},{"id":"94fdcfdf.a00b","type":"server","z":"","name":"Home Assistant","addon":true}]
Link to comment
Share on other sites

Bambu Utila

 

This should do it.

 

5eb7ef0294c0e_Capture.png

[{"id":"70ad660a.1affd8","type":"tab","label":"Emby","disabled":false,"info":""},{"id":"1cd68751.669e69","type":"server-state-changed","z":"70ad660a.1affd8","name":"Living Room Emby","server":"94fdcfdf.a00b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.emby_living_room_tv","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":55,"y":86,"wires":[["a753b9f6.0981f8"]]},{"id":"45985604.63f4c8","type":"switch","z":"70ad660a.1affd8","name":"Play State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"playing","vt":"str"},{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"idle","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":375,"y":86,"wires":[["8df30326.c3499"],["b9882bdc.214d08"],["f336d2a8.6c16e"]]},{"id":"1b7db285.4b210d","type":"api-call-service","z":"70ad660a.1affd8","name":"Dim to 80%","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_bulbs","data":"{\"brightness_pct\": 80}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":895,"y":86,"wires":[[]]},{"id":"9a408af.79e2a78","type":"api-call-service","z":"70ad660a.1affd8","name":"Dim to 100%","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_bulbs","data":"{\"brightness_pct\": 100}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":730,"y":146,"wires":[[]]},{"id":"aebd2f79.1a7b4","type":"api-current-state","z":"70ad660a.1affd8","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_bulbs","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":729,"y":86,"wires":[["1b7db285.4b210d"],[]]},{"id":"f336d2a8.6c16e","type":"api-current-state","z":"70ad660a.1affd8","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_bulbs","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":555,"y":146,"wires":[["9a408af.79e2a78"],[]]},{"id":"a753b9f6.0981f8","type":"time-range-switch","z":"70ad660a.1affd8","name":"Sunset","lat":"46.222715","lon":"-64.500891","startTime":"sunset","endTime":"sunrise","startOffset":"-30","endOffset":"+30","x":225,"y":86,"wires":[["45985604.63f4c8"],[]]},{"id":"b9882bdc.214d08","type":"switch","z":"70ad660a.1affd8","name":"Media Type","property":"data.new_state.attributes.media_content_type","propertyType":"msg","rules":[{"t":"eq","v":"movie","vt":"str"},{"t":"eq","v":"tvshow","vt":"str"},{"t":"eq","v":"music","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":555,"y":86,"wires":[["aebd2f79.1a7b4"],["aebd2f79.1a7b4"],[]]},{"id":"8df30326.c3499","type":"switch","z":"70ad660a.1affd8","name":"Media Type","property":"data.new_state.attributes.media_content_type","propertyType":"msg","rules":[{"t":"eq","v":"movie","vt":"str"},{"t":"eq","v":"tvshow","vt":"str"},{"t":"eq","v":"music","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":555,"y":26,"wires":[["71095e8b.73cf7"],["71095e8b.73cf7"],[]]},{"id":"71095e8b.73cf7","type":"api-current-state","z":"70ad660a.1affd8","name":"Lights On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_bulbs","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":730,"y":26,"wires":[["5f634947.d371c8"],[]]},{"id":"5f634947.d371c8","type":"api-call-service","z":"70ad660a.1affd8","name":"Dim to 60%","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_bulbs","data":"{\"brightness_pct\": 60}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":895,"y":26,"wires":[[]]},{"id":"94fdcfdf.a00b","type":"server","z":"","name":"Home Assistant","addon":true}]

 

Thank you so much! This did the trick. Your explanation also made sense.

Now i can tinker a bit further to make it more adjusted to me.

I see you always check if a light is on before you do anything to them, is that just better practice in stead of just setting the state?

One last question, how do you get the structure of the msg object from things lime media_payer.emby?

Edited by Bambu Utila
Link to comment
Share on other sites

MRobi

I see you always check if a light is on before you do anything to them, is that just better practice in stead of just setting the state?

One last question, how do you get the structure of the msg object from things lime media_payer.emby?

I do it to reduce traffic on the zwave network. No sense sending on off command to a light that is already off. For small automations controlling 1 light it really doesn't make a difference. But when I'm running my goodnight routine, or changing to away mode, etc... sending commands to maybe 10 devices instead of 60-70 makes things much quicker. I run HA on a NUC so it's got more than enough power under the hood to handle the state check without slowing things down by an noticeable amount. If I were on an rpi I probably wouldn't do the same.

 

To see the msg in node-red, just branch in a debug node off of the first event state node, double click on it and in the drop down change it from msg.payload to complete msg object. Deploy the flow and when your event fires you'll see the entire message in the debug panel on the right. It even lets you copy the msg path to the object you want so you can easily throw it into other nodes.

Link to comment
Share on other sites

Bambu Utila

I do it to reduce traffic on the zwave network. No sense sending on off command to a light that is already off. For small automations controlling 1 light it really doesn't make a difference. But when I'm running my goodnight routine, or changing to away mode, etc... sending commands to maybe 10 devices instead of 60-70 makes things much quicker. I run HA on a NUC so it's got more than enough power under the hood to handle the state check without slowing things down by an noticeable amount. If I were on an rpi I probably wouldn't do the same.

 

To see the msg in node-red, just branch in a debug node off of the first event state node, double click on it and in the drop down change it from msg.payload to complete msg object. Deploy the flow and when your event fires you'll see the entire message in the debug panel on the right. It even lets you copy the msg path to the object you want so you can easily throw it into other nodes.

 

Thanks for all that info. It helps out a lot.

 

I managed to get it all working i even use the old_state check for the idle part, so i can still have a different outcome when a movie or tv series was playing. It works like a charm 

Link to comment
Share on other sites

skank

I'm having issues..

HA is on my raspberry pi , running 24/24

Emby is on my unraid server , not 24/24 

If all is running its ok

As soon as i shut down, everything in HA is becoming unavailable (i can live with that)

However when i turn on my server (yes emby automatically restarts too), it doesnt come available until i restart HA !!

 

Anything have to be done to get that working after restart unraid?

Link to comment
Share on other sites

Bambu Utila

 

To see the msg in node-red, just branch in a debug node off of the first event state node, double click on it and in the drop down change it from msg.payload to complete msg object. Deploy the flow and when your event fires you'll see the entire message in the debug panel on the right. It even lets you copy the msg path to the object you want so you can easily throw it into other nodes.

 

This little trick is amazing. This by far gives you the most useful info you can ever get about your entities. Thanks for that!

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
Bambu Utila

I'm having issues..

HA is on my raspberry pi , running 24/24

Emby is on my unraid server , not 24/24 

If all is running its ok

As soon as i shut down, everything in HA is becoming unavailable (i can live with that)

However when i turn on my server (yes emby automatically restarts too), it doesnt come available until i restart HA !!

 

Anything have to be done to get that working after restart unraid?

 

Have you figured this out?

For me it just works. I have HA running in a VM. Emby just native on my windows pc

When i restart Emby, It just gets picked up again by HA.

Link to comment
Share on other sites

Spaceboy

Just installed HA myself and getting going with it but it connected to emby with no issue

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...