I have a python script which reads my smartmeter and sends the values to MQTT items. This happens in a loop so the python script never ends. what is the best way to make this happen on openhab? should I make a service? or forget about the loop, make it one-time executed and let it run every x seconds as a cronjob? I would prefer the loop as the values are more “real-time” but I have no experience in that.
You can use the MQTT binding and subscribe to the corrsponding topics.
That way you immediate updates through MQTT.
Sorry but that is completely not what I’ve asked
Unless you want to get rid of your python script, there’s nothing wrong with this sending values via MQTT to your broker and OH getting them.
In my experience, you should do the calculations (if any) in your python script - like calculation kWh if you only get current consumption and no kWh value from your smartmeter. As the results are much more reliable
or, if it’s really a “smart” smartmeter use the smartmeter binding directly with the IR reader (assuming that your smartmeter is one of those who do have this kind of interface).
I use the sml2mqtt python program to read both my meters and I’ve found it much more pleasant than working with the IR reader binding.
my smartmeter is a Kaifa and I am reading the values over the MBus interface as IR is blocked.
I tried the binding but it failed and so I started to do it with python.
So my question is: How do I configure this python script as a service?
that’s outside the scope of openHAB. OH is a application server, not an OS.
So, depending on your OS you can define the python script as a service.
like the first entry in your google search “linux python script service”:
thank you - will try that
I do not know from which country you are, but there is a DSMR binding where also some Kaifa Smartmeter are supported:
Austria - but I don’t see Kaifa in the list
But you could try
There are a few threads in the forum stating Austrian smartmeter should be supported.
I had planned to connect my Kaifa but will get an extra smartmeter for my PV where I will get data by Modbus.
So I did no longer follow the development of this binding.
Ok I’ve created a systemd service out of my script and it works well!