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

Requesting a function get get power status #51

Open
rsporsche opened this issue Jun 24, 2021 · 0 comments
Open

Requesting a function get get power status #51

rsporsche opened this issue Jun 24, 2021 · 0 comments

Comments

@rsporsche
Copy link

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;
}
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

1 participant