cibernox / homeassistant-poolstation

HomeAssistant custom component for integrating the Poolstation platform.
MIT License
9 stars 4 forks source link

Feature request binary inputs #7

Closed RienduPre closed 6 months ago

RienduPre commented 1 year ago

Hi, I am realy happy with the current integration you have created👏 I appreciate the work you put into it.

I use 2 binary sensors for the water level of my pool. I saw this feature is on your todo list and hope you can find time implement this. Having this functionality I can automate some events based on high or low water level.

Thanks in advance,

Rien

RienduPre commented 1 year ago

Any comments on this, is it possible to help you?

cibernox commented 1 year ago

@RienduPre sure, if you know a little bit of python (I know very little myself) you totally can help, adding a new sensor shouldn't be too hard. Besides, I don't have use the binary entries so it would be harder for me to test if it actually works.

straybiker commented 1 year ago

If am I am correct, you are using pypoolstation. Looking into that code, I don't see references to sensor input. So that would make things harder to develop. Correct?

cibernox commented 1 year ago

@straybiker I created pypoolstation, so we can make any change we need. The problem is that the API is not documented and I don't use the binary inputs or ORP sensor, so I don't know what field in the hundreds (literally, hundreds) of fields in the API's response to look for.

Then names are not very helpful either, these are for instance the ones I figured out that contain temperature, salt concentration, target ph and current ph: Screenshot 2023-06-15 at 15 05 42

It's mainly a matter of knowing where to look.

RienduPre commented 1 year ago

How do you get this list?

you can simply shortcut an binary input on the printboard and see if the value changes from 0 to 1

cibernox commented 1 year ago

This is just one of the requests made to the api every few seconds when you check your pool in https://poolstation.net

RienduPre commented 1 year ago

This is just one of the requests made to the api every few seconds when you check your pool in https://poolstation.net

Ok but how do I execute such a request?

cibernox commented 1 year ago

They are made automatically every few seconds to refresh the information on the page.

RienduPre commented 1 year ago

Forgive me my ignorence, but I still don't know how to do that adn generate the list you shown us in the screenshot

cibernox commented 1 year ago

You can see them in the dev tools of the browser Screenshot 2023-06-15 at 16 06 27

RienduPre commented 1 year ago

What I found sofar is: THe status of the four relais:

cibernox commented 1 year ago

I assume you mean the binary inputs, right? Because the relays have worked for a while now.

RienduPre commented 1 year ago

No I'm searching for the binary inputs right now

straybiker commented 1 year ago

The inputs are just potential free inputs. I wired them so I can easily make the contact to test and check the api response. But it has to wait till next week.

RienduPre commented 1 year ago

I found them.

They are d1, d2, d3 and d4

0 = open, 1 = closed Scherm­afbeelding 2023-06-15 om 17 23 13

RienduPre commented 1 year ago

I'm having trouble to setup a HA development environment on my M1 mac, so I'm unable to do some programming myself and my python knowledge is also very limited

RienduPre commented 1 year ago

I also like to have an indicator if the waterflow is OK.

It looks like this is the ac variable 1 = OK 0 is not OK

cibernox commented 1 year ago

Let me handle the pypoolstation update first to expose the binary sensors and that waterflow one too. Hopefully tonight.

For setting up HA in an M1 mac, I'd suggest to use VSCode with the docker extension installed. As soon as you open the project it should detect that it has a dockerfile and ask if you want to reopen it in a container.

cibernox commented 1 year ago

I've published a new version of the pypoolstation that also parses the state of the binary inputs and also their names, because they are configurable. Initially they are "D1", "D2", etc..., but in your very screenshot you've renamed one of them to "Test1". This can be useful to create the entities in home assistant with a more helpful name. I also parsed the waterflow, which can useful to create a binary sensor with device type "problem", which is a special type of sensor that when its state is ON home assistant will report it in the UI. I've created one for when my heat recuperator tells me that the filters need cleaning and I found it handy.

It's a bit late to make the changes to the integration, I'll try to find time tomorrow.

cibernox commented 1 year ago

Update: It turns out this integration was quite outdated with modern idioms for home assistant, particularly on how number entities worked. tl;dr; Some behavior was deprecated and it would have stopped working in 2023.10. I first took care of updating and cleaning everything.

Now I think I can start adding more features. In the next few days....

cibernox commented 1 year ago

I added the waterflow binary sensor. It can be either OK or Problem.

Binary sensors for the digital inputs will come next.

cibernox commented 1 year ago

I've added support for the digital inputs, but for now they are just named digital_input_1, digital_input_2, etc... Since poolstation allows to give them aliases, I need to investigate if I should try to give them the same names in home assistant.

RienduPre commented 1 year ago

Works great sofar👍 Thanks for your effort.