I'm using python-cec with home assistant to detect whether my television is on or off. The is_on() function satisfies this but I find it illogical that transitioning to on is considered 'off' and transitioning to standby is considered 'on'. For my purposes, transitioning to on means that the tv has been turned on, and anyway, if the tv is not 'on' when transitioning to on then I would expect the same when transitioning to off.
If there was a function that returned the power status including these transition states rather than just the boolean true/false of is_on() then I could apply my own logic to these states.
e.g. something along these lines:
static PyObject * Device_power_status(Device * self) {
cec_power_status power;
Py_BEGIN_ALLOW_THREADS
power = adapter->GetDevicePowerStatus(self->addr);
Py_END_ALLOW_THREADS
PyObject * ret;
switch(power) {
case CEC_POWER_STATUS_ON:
ret = "CEC_POWER_STATUS_ON";
break;
case CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY:
ret = "CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY";
break;
case CEC_POWER_STATUS_STANDBY:
ret = "CEC_POWER_STATUS_STANDBY"
break;
case CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON:
ret = "CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON";
break;
case CEC_POWER_STATUS_UNKNOWN:
default:
PyErr_SetString(PyExc_IOError, "Power status not found");
return NULL;
}
Py_INCREF(ret);
return ret;
}
I'm using python-cec with home assistant to detect whether my television is on or off. The is_on() function satisfies this but I find it illogical that transitioning to on is considered 'off' and transitioning to standby is considered 'on'. For my purposes, transitioning to on means that the tv has been turned on, and anyway, if the tv is not 'on' when transitioning to on then I would expect the same when transitioning to off. If there was a function that returned the power status including these transition states rather than just the boolean true/false of is_on() then I could apply my own logic to these states.
e.g. something along these lines: