[SOLVED]----------------------------------------------------------------
I managed to understand how to configure home assistant via modbus to a siemens logo!
I have a 230V logo but the operation is the same on any siemens logo! that supports modbus TCP.
I’ll put my fully functional configuration below, hoping it can help someone.
I have a system that uses push buttons, not switches. But the operation is almost the same. For me who have push buttons, in LogoSoftComfort it is necessary to use the “current impulse relay” block indicated with the letters “RS”. And on the home assistant you have to create a script (I have yet to do it) that generates an impulse, or you use the very intelligent solution introduced by Moonlight_guest.
In practice I leave below the image of the LogoSoftComfort program and the code to put in the configuration.yaml file in the home assistant. In practice, the secret is to set Logo as a Modbus Server, as shown in this simple YouTube video. Doing so automatically activates a system that allows a modbus client (in this case Home Assistant) to read Logo’s digital Q outputs, without setting network output or other things. The addresses to read the coils are the following which I leave in the table below. ATTENTION: this is something that I discovered: some modbus clients start counting from 1 and some from 0. The Home Assistant modbus client starts counting from 0. So what you will find around is called in German “startadresse” in Home Assistant is equal to 0. I therefore load the table below, corrected for Home Assistant and for all those other modbus clients that start from 0 (such as the python library “pyModbusTCP” found at this link)
now it remains to understand how to control the inputs. Unfortunately as you read here you cannot directly control a coil (coil = output) which has been implemented as an output controlled by a physical button in LogoSoftComfort. This may seem counterintuitive, but it is not. If you read the link just mentioned it will show you why. So let’s understand how to control the exits. The secret is to create a virtual input which in turn controls the output, and this works.
Without messing up between memory of variables, registers, network inputs, network outputs, etc … you can simply create the “merker” block (maybe FLAGS in english… in italian I have written merker) indicated with the letter M and this will be a sort of input, but our Home Assistant will see it as a coil, which can be activated by a switch. Then we on Home Assistant will use the switch to activate the merker which will give a signal parallel to a physical input (using an OR) and activate / deactivate the digital output Q. Then automatically via always modbus a HA (home assistant) will occur update that will show the output on / off (a digital Q output translates to a binary_sensor in HA, look under my code).
ATTENTION: it depends on the version of your logo if you have the merker available. Look in the logo documentation, or in LogoSoftComfort by clicking on your logo in the list on the left and right clicking, properties, hardware type. There it is written if and how many flags you have. I have Logo! 8.FS4 230RCE 0BA0
Look at the addresses below for digital outputs and merker/flags from the table below
Now, this is the Logo SoftComfort (LSC) program
And this the configuration of configuration.yaml on HA:
That I report here as text so you can copy easy. If you are new to the HA world (like me) you can download FILE EDITOR from HA to edit the configuration.yaml
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
modbus:
name: hub1
type: tcp
host: 192.168.1.118
port: 502
switch:
- platform: modbus
scan_interval: 1
coils:
- name: Switch1
hub: hub1
slave: 1
coil: 8256
- name: Switch1
hub: hub1
slave: 1
coil: 8257
binary_sensor:
- platform: modbus
scan_interval: 1
coils:
- name: Q1
hub: hub1
slave: 1
coil: 8192
device_class: light
- name: Q2
hub: hub1
slave: 1
coil: 8193
device_class: light
- name: Q3
hub: hub1
slave: 1
coil: 8194
device_class: light
- name: Q4
hub: hub1
slave: 1
coil: 8195
device_class: light
- name: Q5
hub: hub1
slave: 1
coil: 8196
device_class: light
and so on…
if you want you can use the suggestion I have already mentioned to make a switch in HA (or even physical) behave like a push button. You can find it in this topic up here above
Personally, I want to set HA to give me a short boost, rather than keeping it as a switch.
So the next challenge is to figure out how to generate the impulse on HA, and then how to put that in the HA dashboard see the light bulb and that clicking on it turns on. For the moment I clearly see the binary sensor and the switch.
I keep you updated.
Thanks to everyone for helping me get here, especially at Viktors_Linovs and Moonlight_Guest and gliena