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

IOTA pump is not exposed #13

Open
brettonw opened this issue Aug 24, 2022 · 18 comments
Open

IOTA pump is not exposed #13

brettonw opened this issue Aug 24, 2022 · 18 comments

Comments

@brettonw
Copy link
Contributor

HA no longer has an IOTA integration, so I hoped my Sicce pump would be exposed through the Apex. It shows up in the rest interface, but I imagine that will require some custom coding to control it.

@brettonw brettonw changed the title My iota pump is not exposed IOTA pump is not exposed Aug 24, 2022
@itchannel
Copy link
Owner

Could you please provide a copy
Of your status.json from your controller so I can see the information required for adding it.

@brettonw
Copy link
Contributor Author

status.json.txt

Not strict JSON, but should do. It is a control value as well.

@itchannel
Copy link
Owner

itchannel commented Aug 24, 2022

Thanks for the output I can see your Sicce pump in the outputs. What exactly can you control on it from HA.

status: [
				"TBL",
				"75",
				"OK",
				""
			] 

I'd need to work out what TBL and the "75" value are. I'm guessing "75" is the pump intensity.

@brettonw
Copy link
Contributor Author

brettonw commented Aug 24, 2022 via email

@brettonw
Copy link
Contributor Author

I changed it to not use the wizard, just a "Set 75". The status changed too (I also changed the pump name).

{ status: [ "AON", "75", "OK", "" ], intensity: 75, name: "Sicce_Return", gid: "", type: "iotaPump|Sicce|Syncra", ID: 19, did: "3_1" }

@itchannel
Copy link
Owner

Thanks. Out of interest how did iOTA represent this entity in HA. I'm thinking a sensor showing intensity (Service to change intensity) and a switch with current mode. Other alternative is to use a fan sensor to represent the pump (if doable)

@brettonw
Copy link
Contributor Author

I never got IOTA to work. HA removed the "official" integration and I haven't found another. I was really hoping for it to be exposed here. ;) I think it can be exposed exactly like a variable. How are you reverse engineering the REST interface? There must be a way to send the actual program numbers to the interface.

@itchannel
Copy link
Owner

itchannel commented Aug 25, 2022

I'm not even bothering with a proxy just using network tools in the browser as it's a simple json rest API. I'm going to guess that adding the ability to set variables is as simple as sending the same json as toggling outputs but adding in the percentage variable. If that is the case then it's fairly easy to add.

If you have 5mins could you use dev tools/network in your browser and send me the output of the post request that is sent to the controller when you change the intensity of your pump.

@brettonw
Copy link
Contributor Author

Request URL: http://apex.local/rest/config/oconf/3_1
Request Method: PUT

Payload:
{ "name": "Sicce_Return", "icon": "Up/Down Arrows", "ctype": "Advanced", "log": false, "inuse": true, "type": "iotaPump|Sicce|Syncra", "did": "3_1", "gid": "", "gtype": "0", "ID": "19", "prog": "Set 75\n", "extra": { "temperature": true, "gph": { "min": 0, "max": 0 }, "modes": [ { "id": 0, "name": "Constant" }, { "id": 1, "name": "Lagoonal ripple" }, { "id": 2, "name": "Sharp break" }, { "id": 3, "name": "Reef crest" }, { "id": 4, "name": "Slow current" }, { "id": 5, "name": "Fast current" } ] } }

Response:
{"name":"Sicce_Return","icon":"Up/Down Arrows","ctype":"Advanced","log":false,"inuse":true,"type":"iotaPump|Sicce|Syncra","did":"3_1","gid":"","gtype":"0","ID":"19","prog":"Set 75\n","extra":{"temperature":true,"gph":{"min":0,"max":0},"modes":[{"id":0,"name":"Constant"},{"id":1,"name":"Lagoonal ripple"},{"id":2,"name":"Sharp break"},{"id":3,"name":"Reef crest"},{"id":4,"name":"Slow current"},{"id":5,"name":"Fast current"}]},"errorCode":0,"errorMessage":""}

@brettonw
Copy link
Contributor Author

The "extra" part doesn't seem to actually be applicable to the settings unless you are trying to send a schedule. The screen in apex fusion is like this:
Screen Shot 2022-08-24 at 11 01 17 PM

@brettonw
Copy link
Contributor Author

but switching back to advanced mode, just like a variable:

Screen Shot 2022-08-24 at 11 03 11 PM

@brettonw
Copy link
Contributor Author

brettonw commented Aug 28, 2022

Confirmed I can turn the switch on an off like an outlet. Next is testing whether the set variable service works on it too.
Can you expose the sicce pump as a sensor variable the same way any other variable is? I know I can access the intensity attribute, but I'm wondering about whether it should be exposed as an input_number.

@brettonw
Copy link
Contributor Author

Using the developer tools, I tried to call set variable on the pump and it does not work ("unknown error" is reported). The log contains:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 646, in handle_execute_script
await script_obj.async_run(msg.get("variables"), context=context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1513, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 405, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 449, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 472, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 447, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 680, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/config/custom_components/apex/init.py", line 74, in async_set_variable_service
await hass.async_add_executor_job(set_variable, hass, service_call, coordinator)
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/apex/init.py", line 99, in set_variable
did = service.data.get("did").strip()
AttributeError: 'int' object has no attribute 'strip'

Would you like me to enable logging and try again?

This is important because I don't run the pump at 100% (on/off). I run it at 50%-75%.

@brettonw
Copy link
Contributor Author

The problem seems to be that the did for this object is "3_1", which is getting converted to an integer somewhere in the read from the setup. Adding quotes around it in the call solved that.

@brettonw
Copy link
Contributor Author

brettonw commented Aug 28, 2022

The only problem now is that the IOTA pump is not included in the sensors list (excluded by line 22 of sensor.py?). Since I am controlling the pump via an input_number, it's not really material, but it would be nice to be able to verify that the pump is actually set to the value I requested.

@itchannel
Copy link
Owner

Using the developer tools, I tried to call set variable on the pump and it does not work ("unknown error" is reported). The log contains:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 646, in handle_execute_script await script_obj.async_run(msg.get("variables"), context=context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1513, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 405, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 449, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 472, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 447, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 680, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/apex/init.py", line 74, in async_set_variable_service await hass.async_add_executor_job(set_variable, hass, service_call, coordinator) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/apex/init.py", line 99, in set_variable did = service.data.get("did").strip() AttributeError: 'int' object has no attribute 'strip'

Would you like me to enable logging and try again?

This is important because I don't run the pump at 100% (on/off). I run it at 50%-75%.

Interesting little bug, looks like HA auto converts inputs to integers and strings depending on whats input. I'll just cast the input always to a string and that should fix that use case and avoid the quotes

@itchannel
Copy link
Owner

The only problem now is that the IOTA pump is not included in the sensors list (excluded by line 22 of sensor.py?). Since I am controlling the pump via an input_number, it's not really material, but it would be nice to be able to verify that the pump is actually set to the value I requested.

I can add it back as a sensor if it would be of use. Also as mentioned I am looking at putting pumps as a proper sensor type like a fan 👍

@brettonw
Copy link
Contributor Author

As a test I changed line 22, and I have the sensor value showing up now, so it really is that simple. I'm debating whether to try to set my input number if it changes, but I'm worried about some sort of backlash effect. I'll try it.

@brettonw brettonw mentioned this issue Sep 13, 2022
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

2 participants