Issue converting to int for ozw service call

I am attempting to use a state attribute to set a ozw.set_config_parameter. I am currently getting the following error Failed to call service ozw/set_config_parameter. '>' not supported between instances of 'str' and 'int'.

Below is my sample service data and a screenshot of the corresponding sensor data it’s referencing.

node_id: '12'
parameter: '13'
value: '{{ state_attr(''sensor.purple_air_quality_aqi'', ''colorv'') }}'

This is all to get https://github.com/stjohnjohnson/purple-air.py working. Very excited!

Based on the ozw code, it looks like you’re passing a string as the config parameter value and it expects an integer.

That part I’ve got. I’m unclear how to convert the string to an int in HomeAssistant. I’ve tried wrapping it in int(), removing the single quotes, played with brackets etc. The value seems to be a int and based on the script that is populating the data, it looks like this value is an int and also not a string.

Ah, I didn’t notice you were using colorv, not color. I wonder if your quotes are causing a problem. I would write it as follows:

node_id: 12
parameter: 13
value: "{{ state_attr('sensor.purple_air_quality_aqi', 'colorv') }}"

If not that, try the int filter.

node_id: 12
parameter: 13
value: "{{ state_attr('sensor.purple_air_quality_aqi', 'colorv') | int }}"

hmm. Neither seem to work. Both return the same str error.

Yeah, you’ve hit a bug. The ozw code is not explicitly converting the string to an integer until after some range checking.

If you manually call the service this way, it will work, as long as the value is an integer.

node_id: 12
parameter: 13
value: 21

I am able to manually execute the service with a “hardcoded” int. Sounds like I’ll be unable use this as desired until the bug is fixed in ozw. Do you know the proper place to file the bug? Is it in the QT5 Wrapper for OpenZWave github repo or the main OpenZWave repo?

This is a core HA issue for the ozw integration. I believe @firstof9 is already making a fix.

There we go.

Damn ya’ll are fast :smiley: :star_struck: Once the PR is merged, will I need to wait till the next version release in-order to take advantage of the fix?

Correct, it might get slipped into the next build release ie 0.115.3 (if there’s one in the works)

awesome. Thanks again for the fix!

1 Like

Can I assume you are testing this using Dev Tools? If you put the service call in an automation with the template, it should work fine. It looks like it’s just a problem using Dev Tools.

Hmm, it wasn’t working with my automation, so I flipped over to DevTools to figure it out. I’ll give it another shot in the automations. I just setup Node-Red so I’ll give it a shot there as well.

Looks like everything is working! I originally tried the automation with the size data attribute which OZW didn’t like, then I went to troubleshooting in the Dev Tools. Once I removed the size element from the Automation, everything is working. I also got the Node-Red flow working!

I looks like it has always been the case that you can’t use templates in Dev Tools. At least, a better error message should be added.

Agreed. I would have thought the Dev Tools would have been the spot to play around with the templates… I distinctly remember giving up on a template, I think it may have been because of this. :frowning: