rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.95k stars 563 forks source link

Add support for helper platforms #253

Open postlund opened 3 years ago

postlund commented 3 years ago

We should add generic support for the helper platforms, e.g. everyone named input_ to support the various odd-cases we might find.

ultratoto14 commented 3 years ago

@postlund can you describe a bit more what you're thinking about, or just put an example ?

postlund commented 3 years ago

@ultratoto14 An imaginary example would be a DP that expose the current speed of a fan as an integer and allows changing the speed by setting a new value. By providing an implementation of input_number, we can support those kinds of use cases. I happen to own a LED string from DELTACO that supports eight different light modes (scenes) which are just represented by an integer. input_number would work for that.

Not all helpers are relevant as some are implemented best by another platform, e.g. switch can be used instead of input_boolean.

ultratoto14 commented 3 years ago

Ok, i was thinking of the same but using the new blueprint feature. Do you imagine internal mapping in that case ? Displayed value and sent value for each entry ?

postlund commented 3 years ago

I'm not sure how blueprint fits the picture here? You mean like use a sensor in conjunction with the set_dp service and hide it behind some config in the blueprint?

I just imagine that you specify min, max and step length more or less when adding the entity and let the DP value map to that range (with some error handling I case there's a mismatch). When changing the slider/using increase or decrease, that value would be written to the DP. Nothing fancy-schmancy.

ultratoto14 commented 3 years ago

I was thinking of the input select with different scenes, it's like a combo, I would in that case, prefer having a combo with scene names than just numbers, that may send simple or complex data using set DP.

ultratoto14 commented 3 years ago

Yes for sliders(input_number), totally following you

postlund commented 3 years ago

Yeah, input_select is a bit more complex as we are limited in what we can do. We have a few alternatives as I see it:

ultratoto14 commented 3 years ago

Aaahhh, didn't know you are also working on remote homeassistant, it seems that it's not the first time you saved my life 😄

Will check tomorrow

postlund commented 3 years ago

But of course I do 😉

ultratoto14 commented 3 years ago

I like the way remote_homeassistant let you add events. Great job again. Maybe a mix of your two first points, the way it's done in remote_homeassistant and Night=1 when we add an entry, it may be optional, we can use 1 or Night=1