Sky Q box switch

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!!!

Im struggling to get this to work - even on the cmd line:

pi@hassbian:~ $ sudo python3  /home/homeassistant/.homeassistant/custom_components/sky/skyq.py {135}
  File "/home/homeassistant/.homeassistant/custom_components/sky/skyq.py", line 89
    print "no parameters"
                        ^
SyntaxError: Missing parentheses in call to 'print'
pi@hassbian:~ $

and from home assistant when i try to run the service from the services i get:

Failed to call service shell_command/cmd_skyq_chno. [Errno 8] Exec format error 

Any ideas? I assume I’m running it on the cli wrong?

Thanks in advance

It’s a python 2 script, and your arguments aren’t formatted correctly. Try either

python  /home/homeassistant/.homeassistant/custom_components/sky/skyq.py chno 135

or just

/home/homeassistant/.homeassistant/custom_components/sky/skyq.py chno 135

Thanks all for the above. Relatively new to HA and been playing about well with the config and lovelace yaml’s, however all of the above has just blown my mind. any chance someone could call out the required steps of what code needs to go where ? i’m using a Pi3?

thanks in advanced

I keep getting an error when running the command.
‘Return code 127’
Does anyone know how to fix this?
Thanks in Advance

2 Likes

Would be great if someone could create a task so that you could get a misplaced remote control to beep.
This can be done by pressing the button on the front of the sky box for 5 seconds. If it could be added to HA it would be a killer feature.

having problems with this and wondering if someone can help, the web page works and updates the status in real time so I think there may be something needing altered in the value template… but I know nothing about it to be able to make a change.

here is what I have in my binary_sensors.yaml

- platform: rest
  resource: http://192.168.0.13:9006/as/system/information 
  name: SkyQ Lounge Power Status
  device_class: power
  value_template: ‘{% if (value_json.activeStandby == False) %}on{% else %}off{% endif %}’

as this is 4 years old I’m guessing it needs o be updated but like I said I have no idea how… any help please?

thankyou in advance

Unsure what exactly your issue is based on your comments. I have recently used some of the content above without issue, below is currently working for me.

Thanks for your reply, the issue is that the state does not update in home assistant. The sensor shows up with a state of “off” but remains off when I turn on the sky q box.
If I navigate to the resource url directly then the attribute the sensor is “reading” does indeed change to show the real-time state of the sky q box.

I noticed that you have it as a sensor, while above it is a binary_sensor so I tried both, however I have the same result, the only difference I can see is in the binary_sensor the state shows as off and in the sensor it shows as ‘off’ (notice the inverted commas).

I an to use this to turn my TV off with the sky q box using my broadlink rm Pro.

Any help is appreciated, thank you

Robin, I ran a test and agree with you, the binary_sensor does not work for me either in HA.

I’m not familiar enough with binary_sensor to explain why this is. The documentation suggests this should work. Can you explain the value of a binary over standard sensor?

Perhaps the solution is we use the media player instead of using the rest call.

All I can suggest is using the standard sensor, it works perfectly for me. :wink: