Sending data from Home Assistant to Loxone

Hi all.

I recently bought a Loxone miniserver in a transition from HA to Loxone.
Some devices, like my digital grid meter, are not easily integratable in Loxone (but are in HA).

I’ve been investigating a lot on how to easily send data from HA to Loxone. I’m not a big fan of more “heavy” solutions like Loxberry/MQTT, a combination of VO/VI’s in Loxone, etc.

However, I managed to find a very easy, fast and lightweight solution for this: send sensor values directly to a VI in Loxone.

1. Add a rest_command to your config.yaml

rest_command:
  update_loxone:
    url: "http://<LoxoneUser>:<LoxonePassword>@192.168.2.110/dev/sps/io/{{ parameter }}"
    method: GET

2. Add VI('s)
For each sensor you want to send, create a VI in Loxone.
Make sure the VI’s name is exactly the same as the one in HA, minus the domain and the dot separator.

So sensor.tellerstand_afname in HA becomes VI Tellerstand_Afname (not case-sensitive)


3. Load Blueprint
Load this Blueprint and add all sensor values you want to pass.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Home Assistant to Loxone
  description: Send entity states from Home Assistant to Loxone
  domain: automation
  input:
    target_entities:
      name: Trigger entities
      description: List the entities that will be sent to the VI's on the Miniserver
      selector:
        entity:
          multiple: true
          filter:
            - domain: sensor

alias: Update Loxone
description: ""
trigger:
  - platform: state
    entity_id: !input target_entities
condition: []
action:
  - service: rest_command.update_loxone
    data:
      parameter: "{{ trigger.entity_id.split('.')[1]  }}/{{ trigger.to_state.state  }}"
mode: parallel
4 Likes

Hi @gigatexel,

I just tried to import the blueprint but got an error: “No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.”

Could you please check, whether the blueprint embedding is ok?
Thanks!

Thanks for reporting this. Should be fixed now.

1 Like

Thanks for fixing that, the import works now! I’ll give it a try this weekend.

I tested the blueprint and it works really well! In my case I needed to extend the domain filter to match binary_sensor to be able to send some values from reolink doorbell to loxone. Good work and thanks for sharing! :+1:

Hello @gigatexel

I’m building new house, i bought loxone mini server and in same time I bought also HA.
Can you say me why you are choosen to migrate from ha to loxone ?

This is so handy! I did this using Node Red, but this is just way more elegant: no need for Node read and the Node red Loxone integration :slight_smile:

What I still miss though is the other way around, from Loxone to HA:
I want Loxone to control some HA devices.
Eg: I have some Hue lamps, a Ventilation unit, a Sonoff NS panel, …
This is now also done using Node Red , but may be there is also a better solution?

Maybe this can help? REST API | Home Assistant Developer Docs

Or the pyLoxone integration in HACS.

Hi there,

this is exactly what I am looking for. However, I am struggling with the setup in HA, which sends the following error: “The automation “Home Assistant to Loxone” (automation.home_assistant_to_loxone) has an action that calls an unknown service: rest_command.update_loxone.”

I assume my rest_command is not correct. Can someone please clarify the details of the url? I think LoxoneUser is my Loxone Login, LoxonePassword is my Loxone Password - right? Does 192.168.2.110 stand for my Loxone-IP or for my HA-IP?

I have a web access to my HA (https://[myUserID].duckdns.org:8123) - could this also be a reason for the error I am receiving?

Any support would greatly be appreciated.

Login an password should be for a user that has sufficient rights. Personally I am not yet using multiple user names, so I’m just using my admin credentials.
The IP address is the internal (!) address for the loxone miniserver.

thank you, gigatexel!
unfortunately I still receive the same error, using the internal address of the Loxone miniserver (tried with and without the port [:98] at the end) and my admin credentials. I am sure I have no typos in address and credentials.

Anything in the logs? Is the rest_command present in the Developers Tools → Services page?

Nope. Other rest_commands are present. The URL is correct - when entering in a browser I reach the Loxone Login site. I also tried to put username and password in separate lines like below - no success.

rest_command:
update_loxone:
url: http://LoxoneIP:98/dev/sps/io/{{ parameter }}
username: admin
password: LoxonePW
method: GET

You say you have other rest commands. You can only have one rest_command statement in your config file. You have to group all your rest commands together.
Please provide a screenshot or formatted text.

Thank you so much! Works like a charm now. I am used to split the config.yaml in different packages in order to have an easier overview. After grouping the rest commands in one packages, your solution works flawlessly.

Thank you, this is exactly what I need. I encountered pretty confusing error (but solved it). So here it is, may it help somebody.

Template variable error: 'dict object' has no attribute 'entity_id' when rendering '{{ trigger.entity_id.split('.')[1] }}/{{ trigger.to_state.state }}'

(For context: I am trying to send 24 values from sensors that represents prices of electricity on day market. Sensor just wraps API call and gets those values.)

Problem is, the rest sensor does not have (cannot have) entitiy_id in the config.

SOLUTION: was to open every sensor in the UI, change some stuff (icon for example) and save it. This re-save probably set the entity_id and therefore solved the issue.

Update: It is not working. Sometimes it goes through but then it fails again. entity_id is somehow still missing. :frowning:

Update2: Entity ID is missing only when you try to run this manually from the UI. As trigger is bound to state change it wont work from the UI (triggering it manually, as it doesn’t know the entity). I have wasted sooooo much time on this. :frowning:

1 Like

Are you aware that Loxone can get electricity market prices itself?

Yes but unfortunately you cannot use them in your own logic.

Due to legal restrictions of the spot market data providers, we cannot provide access to the data. The statistics are only displayed in the user interface.

I also want to add distribution costs to the price (spot is only pat of the cost of electricity). Here where I live (Czechia) we have some cheap and expensive hours (it is quite complicated, but in a nutshell the final price of electricity is changed by some local rules).

Update: It is not working. Sometimes it goes through but then it fails again. entity_id is somehow still missing. :frowning:

Update2: see original message, problem was that it wont work from UI

@gigatexel many thanks for this Blueprint! te Gek! :wink:

@oglx can you maybe help me? When I use a sensor like specified in the domain filter, I can receive data in Loxone. But when I want to use a binary_sensor (also for the Reolink doorbell) or a device_tracker, I just cannot get it to work. What am I missing? What was needed to expand this domain filter to not only work for sensors?

Hope you can help me out!

Correction: I found the issue. The device_tracker gave a string output… I did not use a VI string input in Loxone. All works fine!