Use REST Notify to push a Value to Loxone API

Hello
i am stuck,
i already manages to push a value which is fixed f.e. 44 to the loxone value that works,

notify:
  - name: whirlpool_temp
    platform: rest
    resource: http://admin:[email protected]/dev/sps/io/VI1/44

but i when i want to add here the temperature value nothing happens.

notify:
  - name: whirlpool_temp
    platform: rest
    resource: http://admin:[email protected]/dev/sps/io/VI1/{{ states.water_heater.my_lay_z_spa.state }}

whats wrong here ?

thanks

Also tried {{ state_attr(‘water_heater.my_lay_z_spa’, ‘current_temperature’) }}

But nothing works…

notify:
  - name: whirlpool_temp
    platform: rest
    resource: http://admin:[email protected]/dev/sps/io/VI1/{{ state_attr('water_heater.my_lay_z_spa', 'current_temperature') }}
    

Most probably the resource field doesn’t support templates. The docs say nothing about it, which in most cases means that it’s not templatable.

ok but how elese is a way to push that value to a api below, or also i connected it to PyLoxone and then the Vi1 shows as imported binary sensor “sensor.whirlpool_temoeratur”

How must be a scriot or automation look to update every minute the value:
sensor.whirlpool_temoeratur
with
water_heater.my_lay_z_spa-state ?

As far as I can tell it’s not possible. Make a Feature request to make the resource templatable and if you’re lucky, someone will pick it up.

Did you try the custom Loxone component?

Yes thats what i mentioned warlier i already installed this binnding.

now i have both sensors als entitities.

How can i force every minute to update one entitity value with another

or is this also not possible with homeassistant ?

water_heater.my_lay_z_spa.state   ->     sensor.whirlpool_temperatur


Sorry, I don’t get it. Are these both entities from Loxone? And with updating one sensor with the value, do you mean only in Home Assistamt or in Loxone?

Sorry may i didn´t give much explanation what i plan to do.

I have installed with hacs a integration for my lay z spa hottub, so i am able to see the actual temperature in Homeassistant. this gives me the entity water_heater.my_lay_z_spa.state

But i primary use loxone, i just have HA in a pi for playing a but and use it for my hottub :slight_smile:

So not i want to push the value of the water temperature from the HA integration to the loxone binary sensor entity sensor.whirlpool_temperatur that all my other loxone devices in my ouse can see the temp.

Hope now you understand what my plan is,

Thanks

I don’t use Loxone, but from my underatanding it should work with the following automation with the loxone integration:

trigger:
  platform: state
  entity_id: water_heater.my_lay_z_spa
  attribute: current_temperature
action:
  service: loxone.event_websocket_command
  data:
    uuid: "152ecfaa-03ac-f715-ffff403fb0c34b9e"
    value: "{{ state_attr('water_heater.my_lay_z_spa', 'current_temp')|float }}"
  

Replace UUID with the value (I suppose you had to do this already to get the Loxone sensor into HA)
This will trigger every time the water_heater entity’s attribute current_temperature changes and sends the new value to Loxone via Webhook.

1 Like

thats it ! thanks a lot ! have a nice weekend

1 Like

In case you need to send quickly changing value to Loxone (i.e. from power meter) websocket might not be the best solution. It had some undesirable side-effects for me (see the issue here) so I switched to sending the data other way. You have either the option to send data to Virtual Input as you originally wanted or maybe even better going through UDP.

You need to first define shell commands for each of the ways:

shell_command:
  loxone_udp: /bin/sh loxone_udp.sh "{{ value }}"
  loxone_vi: curl -X GET -H "Authorization:Basic xxxREDACTEDxxx" http://MINISERVER_IP/dev/sps/io/"{{ vi_name }}"/"{{ value}}"

For UDP you also need to create a simple shell script (i.e. by using the “Terminal & SSH” addon) in the config directory and make it executable.
I have called it loxone_udp.sh :

#/bin/sh
echo "$1" | nc -u -w1 MINISERVER_IP MINISERVER_PORT

Then you can use it from an automation like this:

service: shell_command.loxone_udp
data_template:
  value: "pcpower{{states.sensor.pc_power.state | float(0) * 0.001 | float }}"

or

service: shell_command.loxone_vi
data_template:
  vi_name: VI##
  value: "{{states.sensor.pc_power.state | float(0) * 0.001 | float }}"

For UDP you need to create the UDP input in Loxone with correct UDP command (like pcpower\v for my example above).

The reason why it didn’t work for you using the REST Notify are most probably the templates. I have fought with them for some time till I gave up and found a way using this shell command.
I also think it is a bit safer to use the basic auth hash than plain text password if you decide to choose http. I prefer UDP as it is lighter.