Sky Q box switch

sorted by using absolute path. Now working a charm !
If you dont mind me asking, did you hook that to alexa some nice way?
All I did just created input_boolean for on off using emulated hue but wonder if you can actually pass voice commands ?

Incorporate current status into an on/off switch for Sky Q Boxes.

binary_sensor:
  - platform: rest
    resource: http://192.168.1.15:9006/as/system/information
    name: sky_q_living_room_power_status
    device_class: power
    value_template: '{% if (value_json.activeStandby == False) %}on{% else %}off{% endif %}'

script:
  sky_q_living_room_power:
    alias: Toggle Sky Q Living Room power
    sequence:
      - service: shell_command.cmd_skyq_lr_command
        data_template:
          command: 'power'
      - service: shell_command.cmd_skyq_lr_command
        data_template:
          command: 'backup'

switch:
  - platform: template
    switches:
      sky_q_living_room:
        value_template: "{{ is_state('binary_sensor.sky_q_living_room_power_status', 'on') }}"
        turn_on:
          service: script.sky_q_living_room_power
        turn_off:
          service: script.sky_q_living_room_power
2 Likes

For anyone trying to get this to work, it looks like the port has moved to 49160. I’ve got the above code working, but had to replace 5900 with 49160 throughout.

2 Likes

Absolute legend, haven’t used this in a while due to changing configs started it up and it failed!
How did you find out about the port change?

Just did a port scan for open ports on the Sky Q box, then tried them one by one.

Hi @Angarmgmt I was using your code in a RPi3 and it worked fine but now i am using a NUC Ubuntu with docker and its not working.

I get this error.

2018-03-29 15:05:25 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `/config/python_scripts/skyq.py {{command}}`, return code: 1
NoneType: None

Any help please this was a great piece of code.

Hi @cameron,
Do you have a copy of your config for the sky q remote and channels? Looks great would love to utilise some of what you have done.

Thanks

Hi @Baneeshc
I am sorry i am away at the moment but i will but together some thing the weekend.
I have got it working with Node Red so its using MQTT from the HA to Node Red and the Sky Remote Node.

Hi all!

Wondering if someone could help me out with this?

I have the sky.py file setup however I’m unsure where to place this file within home assistant?

Could anyone pass on any advice on this?

Thanks!

I just uploaded to SkyQ and was quite frustrated my sony IR blaster stopped working with the new box. Just wanted to say that this thread gave me exactly what I needed. Thank you - works a treat!

Hi TDM,

Did you get the sky.py working or did you create the binary sensor?

Did you get this working, @wonkydog?

I have got it all working perfectly, and would be happy to help if you want.

:raised_hands::raised_hands:

Thanks for helping!

No joy yet! Will this work on Haas.io? I’m starting to think no?

Also where did you save the sky.py file?

Any help really appreciated! Thanks again!

WD

I don’t use hass.io, so not sure on that point!

It doesn’t matter where your sky.py file is, as long as HA can reach it and you point to it in your configuration file I have done the below:

shell_command:
  cmd_skyq_channel: /home/homeassistant/.homeassistant/custom_components/sky/skyq.py channel {{chname}}
  cmd_skyq_chno: /home/homeassistant/.homeassistant/custom_components/sky/skyq.py chno {{chno}}
  cmd_skyq_command: /home/homeassistant/.homeassistant/custom_components/sky/skyq.py {{command}}

Then you just need to amend the sky.py file so it has the correct IP address of your sky box.

You can set up a sensor as below:

sensor:

  - platform: rest
    resource: http://192.168.1.13:9006/as/system/information
    name: Sky Q Living Room
    value_template: '{% if (value_json.activeStandby == False) %}on{% else %}off{% endif %}'

And I also set a switch up like this:

  switches:
    sky_q_living_room:
      value_template: "{{ is_state('sensor.sky_q_living_room', 'on') }}"
      turn_on:
        service: script.sky_q_living_room_power
      turn_off:
        service: script.sky_q_living_room_power

It can take a few seconds for the Sky box to realise it’s on, and the switch will turn itself off in the meantime. It will change to on if you leave it.

Hopefully this helps!

Thanks for looking into this. Seems like I can actually call the service now however still no response from the sky box when I call the service. Ive just checked the IP address and that is correct but I’ve thought of the following that may be beneficial to my case…

Could you confirm the port number (for commands) you’re using and getting results from?

Could you perhaps tell me the service data that you are sending in your configs/automations? I’m currently trying:

{
  "command": "power"
}

and also;

{
  "data_template": {
    "command": "power"
  }
}

With no apparent luck with either, any thoughts or suggestions from here again really appreciated! Least I seem to be able to call the sky.py file now which is a big step forward so thank you!

WD

Looking a little deeper I’ve found this in the HA logs…

## Log Details (ERROR)

Fri Mar 15 2019 22:27:37 GMT+0000 (GMT)

Error running command: `/config/skyq.py {{command}}`, return code: 1

NoneType: None

Completely forgot to mention that you have to change the port in the sky.py file:

Thanks for that Jonny,

Could you possibly confirm the service data you are passing to the script?

Also any idea about the logs posted above?

Thanks so much!

WD

I am doing the same thing you are:

{“command”:“power”}

I only use it for power at the moment, haven’t had time to add the channels in yet.

I’m not really sure about the logs, I set it up as above and it worked first time!

Works perfectly here, many thanks!!!