Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect "powerStatus" values when switching with the IR remote control #2

Open
Markkuuss opened this issue Jan 3, 2020 · 5 comments

Comments

@Markkuuss
Copy link

Very nice work. I use the module cec-web-api and it works really great. Only when I switch my devices on/off with the remote control, the powerStatus value is not correct.

My problems:

  1. Switching the soundbar on/off with the remote control is not recognized at all. The "powerStatus" always keeps its last state. The state does not change.
  2. When switching on the TV with the remote control, the "powerStatus" remains in the status "in transition from standby to on" and does not change to "on" later.

Regarding 1:

Here is the debug output when switching on the soundbar:

  cec-client TRAFFIC: [          378250]        >> 5f:84:30:00:05 +21s
  cec-controller Received report address request on broadcast +21s
  cec-controller Running command: pow 5 +1ms
  cec-controller dev5 powerStatus is: standby +28ms
  cec-client TRAFFIC: [          378759]        >> 5f:84:30:00:05 +509ms
  cec-controller Received report address request on broadcast +480ms
  cec-controller Running command: pow 5 +1ms
  cec-controller dev5 powerStatus is: standby +21ms

If a device sends the broadcast with the physical address, would it be possible to additionally check the "powerStatus" and set it correctly?

Here is the debug output when switching off the soundbar:

cec-client TRAFFIC: [           62951]        >> 5f:72:00 +32s

I think this would be relatively easy to solve by evaluating the traffic. The broadcast command "...f:72:00" seem not to be evaluated at the moment. If an audio device sets the System Audio Mode to Off, the "powerStatus" is also off.

Regarding 2:

Here is the debug output when switching on the TV:

cec-client TRAFFIC: [          779364]        >> 0f:84:00:00:00 +38s
cec-controller Received report address request on broadcast +41s
cec-controller Running command: pow 0 +1ms
cec-client TRAFFIC: [          779364]        << 4f:84:20:00:04 +3ms
cec-client TRAFFIC: [          779514]        << 40:8f +148ms
cec-client TRAFFIC: [          779698]        >> 0f:87:00:90:3e +183ms
cec-client TRAFFIC: [          779698]        << 4f:87:00:15:82 +1ms
cec-client TRAFFIC: [          780575]        << 40:8f +877ms
cec-controller Updated dev0 powerStatus using stdout to: in transition from standby to on +2s
cec-controller dev0 powerStatus is: in transition from standby to on +1ms
cec-client TRAFFIC: [          780956]        >> 04:90:02 +383ms
cec-client TRAFFIC: [          781171]        >> 04:90:02 +213ms
cec-client TRAFFIC: [          787750]        >> 0f:80:00:00:10:00 +7s
cec-client TRAFFIC: [          789818]        >> 5f:84:30:00:05 +2s
cec-controller Received report address request on broadcast +9s

Similar to the soundbar, the TV probably doesn't report power status automatically when it is turned on with the remote control. It only reports "04:90:02" once, but no "04:90:00" afterwards. This would probably have to be actively requested.

Possible solution

The simplest solution to always guarantee an up-to-date "powerStatus" for all devices would probably be the active cyclic request of the "Device Power Status" (8F) across all devices. Would it be possible to run a thread that queries the "Device Power Status" e.g. every 5 seconds?

@Markkuuss
Copy link
Author

Maybe a simple way would be to add another function "getPowerStatus" for each device to request the "Device Power Status" (8F) and update "powerStatus".

As follows, for example:

{
  "dev0": {
    "name": "TV",
    "logicalAddress": "0",
    "address": "0.0.0.0",
    "activeSource": "no",
    "vendor": "Philips",
    "osdString": "TV",
    "cecVersion": "1.4",
    "powerStatus": "on",
    "language": "ger",
    "turnOn": "function",
    "turnOff": "function",
    "togglePower": "function",
    "changeSource": "function",
    "sendKey": "function",
    "getPowerStatus": "function"
  },
  "dev4": {
    "name": "Playback 1",
    "logicalAddress": "4",
    "address": "2.0.0.0",
    "activeSource": "no",
    "vendor": "Philips",
    "osdString": "CEC-WEB-API",
    "cecVersion": "1.4",
    "powerStatus": "on",
    "language": "eng",
    "turnOn": "function",
    "turnOff": "function",
    "togglePower": "function"
  },
  "dev5": {
    "name": "Audio",
    "logicalAddress": "5",
    "address": "3.0.0.0",
    "activeSource": "no",
    "vendor": "Samsung",
    "osdString": "Soundbar",
    "cecVersion": "1.4",
    "powerStatus": "on",
    "language": "???",
    "turnOn": "function",
    "turnOff": "function",
    "togglePower": "function",
    "sendKey": "function",
    "getPowerStatus": "function"
  },
  "setActive": "function",
  "setInactive": "function",
  "volumeUp": "function",
  "volumeDown": "function",
  "mute": "function",
  "getKeyNames": "function",
  "command": "function"
}

@Rafostar
Copy link
Owner

Rafostar commented Jan 5, 2020

@Markkuuss
Getting "Device Power Status" is not that easy as at least some TVs (if not all) cannot query devices that are connected to them while powered off (traffic does not flow through HDMI switch when TV turned off).

I think this would be relatively easy to solve by evaluating the traffic. The broadcast command "...f:72:00" seem not to be evaluated at the moment.

The current cec parsing code needs to be reworked to allow simpler adding of new traffic commands to monitor. I will try to improve it when I will have access to RPi and see what can be done about the remote power issue.

@Markkuuss
Copy link
Author

Any news on that subject yet? Do you already have access to RPi, @Rafostar ?

@Rafostar
Copy link
Owner

@Markkuuss
Due to COVID pandemic and some other personal problems, I am putting ALL my projects on hold. As you have seen, the current code is real mess. This needs to be rewritten, so it can be faster, cleaner and better. I will be able resume my activity on GitHub sometime in Autumn. I wish I could work on this and other projects, but right now I really can't.

@Markkuuss
Copy link
Author

As you have seen, the current code is real mess.

Yeah, I can see that. :-)

And the change to the readline module doesn't work for me either, because probably this.myDevice is always null. But that would be a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants