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

Add analog_output platform #347

Closed
antonverburg opened this issue Feb 11, 2020 · 9 comments
Closed

Add analog_output platform #347

antonverburg opened this issue Feb 11, 2020 · 9 comments

Comments

@antonverburg
Copy link

Context

For sensors we have the binary_sensor and the sensor platform. For output devices we have the switch, which is essentially a binary output. We do not yet have an analog output platform, that can be used to easily integrate analog outputs (like pwm control of pumps, etc).

Proposal

I am in the progress to create such a platform but I do not have much experience with home assistant, so please help me with a critical review when I post a pull request. Currently I use the switch - and light platforms as examples to build a new platform for a new analog output platform. I will also add an example implementation to test the platform. My code will be available at https://github.com/antonverburg/home-assistant/tree/analog_output?files=1

Consequences

As this is a new and separate development I do not see consequences for other components except from adding code.

@dkagedal
Copy link

Another use case is dimmer control, like in

https://github.com/dkagedal/dimmer

There, I'm using an input_number to emulate an analog output that controls a dimmer controller. Making a dimmer platform for an analog output integration (I think the platform is the implementation, right, not the interface?) would make more sense.

The state that is being controlled here is dimming velocity -/0/+.

@antonverburg
Copy link
Author

antonverburg commented Feb 13, 2020

@dkagedal : why don't you use the light platform?
-> Hm, I already see: you have created a sort of upper layer that controls (a set of) lights by modifying their intensity over time depending on the input value. Still I don't understand fully why you don't use light profiles or the transition property for it...

@dkagedal
Copy link

@antonverburg : I try to explain i in the README.

TL;DR: A light has a "brightness", but it doesn't have the state "currently dimming up". What I'm proposing is to add that state as a separate entity. The analog_ouput would not be tied to the brightness value, but to the dimmer "velocity".

@JeffLIrion
Copy link

@antonverburg I'm not 100% clear on what you're describing, but it sounds like it might be similar to my custom input number component. From the README:

This component is to the built-in input_number what a template switch is to an input boolean. It accomplishes two things:

  1. Its value can track other entities by way of a template.
  2. When its value is changed, it can run a script.

I created a pull request to add it to HA a while ago but it was rejected. Still, I think people would find lots of uses for an integration like this that can control and track* other integrations.

*It doesn't have to track anything, it could be used only for control.

@antonverburg
Copy link
Author

Hi Jeff, it seems that you tried the same as Shulyaka in this thread: #328. I did not yet check your code, but according to balloob in home-assistant/core#22176 you are mixing the input_number code to create a template or platform. Don't do that, an input is an input, and should remain that. What I want is an equivalent for the switch platform that can implement analog output devices.

@JeffLIrion
Copy link

@antonverburg yes, I know that my approach is frowned upon and would be rejected if I submitted it as a pull request to HA. Hence, I keep it as a custom component.

My reason for using the input_number integration is simple: I want a slider in the UI. I'm pretty sure that at one point I tried making my code a separate integration called template_number, but it didn't show up as a slider in the UI. And therein lies the problem:

#328 (comment)

This issue is conflating the concern that you want a slider in the UI with the fact that the input_number integration is rendered as a slider.

I respect that decision, even though I believe that such an integration that allows for templated tracking and automated control would be very useful.

Naming and software architecture aside, I think my custom component can accomplish what you want: you change a slider to x and some device gets set to x. It also works in the opposite direction: when your device gets set to y, the slider gets updated to y.

That's the sort of functionality you're looking for, right? It would be great if that could be added to HA!

@antonverburg
Copy link
Author

@JeffLIrion: Yes, that's exactly what I make.

@antonverburg
Copy link
Author

Implementing the UI I found that there are 2 comparable interface cards: the light card (for a light containing only brightness-configurable channel) and the 'input-number' card. The first one only contains an color-changing icon, a name and a switch-on/off button in row-elements. The later does not change icon color, and contains an icon, a name and a value-input field or slider in row-elements. What is the preferred visualization? To my feelings the first visualization is better. Normally such an output will be controlled by automations, so if the input is only controllable after an extra click is OK, and it gives more space to show the name.

@frenck
Copy link
Member

frenck commented Jan 26, 2021

This has been added: the number entity component.

@frenck frenck closed this as completed Jan 26, 2021
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

4 participants