Converting output to Domoticz smart meter

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
phenix56
Posts: 31
Joined: Sunday 10 October 2021 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Converting output to Domoticz smart meter

Post by phenix56 »

Hi all,

I have a digital (not smart) meter which I can read out via a IR adapter. I have a few lines of code that send the output to /dev/ttyUSB0.

Unfortunately, it has a bunch of other data along with it, so I can't just convert it to a variable and use the API.

In the output, I have added the // at the end of each line along what kind of information it gives. I did not add the white lines, they were added by the converter.
The output looks like this:
/?!

/ISk5MT171-0133 // Model number (I think)

000

0-0:C.1.0*255(47827401) // Unsure

1-0:0.0.0*255(47827401) // Unsure

1-0:0.2.0*255(V1.0) // Firmware version of the converter

1-0:1.8.0*255(035745 kWh) // Total usage

1-0:1.8.1*255(019928 kWh) // Usage high tariff

1-0:1.8.2*255(015817 kWh) // Usage low tariff

1-0:2.8.0*255(030550 kWh) // Total return

1-0:2.8.1*255(023577 kWh) // Return high tariff

1-0:2.8.2*255(006972 kWh) // Return low tariff

FF(00000000) // Unsure

!
How would I convert a output like this to a Domoticz smart meter?

Thank you in advance!
MrScotty
Posts: 3
Joined: Thursday 25 January 2018 18:03
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: netherlands
Contact:

Re: Converting output to Domoticz smart meter

Post by MrScotty »

Looks like a smart meter telegram (google dutch smart meter requirements and you should vind a document from netbeheer nederland; chapter 5 Protocol description describes the 1-0:1. 8 .0 etc)

I would just try the P1 smart meter USB as a type in the hardware section. Don't know if it can handle extra the extra data which comes allong.
If you have the few lines of code you could update the code to filter out the not needed extra information
phenix56
Posts: 31
Joined: Sunday 10 October 2021 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Converting output to Domoticz smart meter

Post by phenix56 »

Thank you for your answer!

I have tried adding the device in Domoticz, but the readings are not right at all. I only see a value of 510.000 without any other data.

Here are the lines of code I am using in a scheduled script to pull the data:
stty -F /dev/ttyUSB0 300 -parodd cs7 -cstopb parenb -ixoff -crtscts -hupcl -ixon -opost -onlcr -isig -icanon -iexten -echo -echoe -echoctl -echoke
sleep 2
echo -n -e '\x2F\x3F\x21\x0D\x0A' > /dev/ttyUSB0
sleep 1.5
echo -n -e '\x06\x30\x30\x30\x0D\x0A' > /dev/ttyUSB0
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Converting output to Domoticz smart meter

Post by waltervl »

This is the code of Domoticz that reads P1 telegrams
https://github.com/domoticz/domoticz/bl ... erBase.cpp

Is your device not not able to be read by some plugin or script already? See for example viewtopic.php?t=11333
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
phenix56
Posts: 31
Joined: Sunday 10 October 2021 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Converting output to Domoticz smart meter

Post by phenix56 »

I do not have much knowledge of scripting and stuff like this, but my output seems to be missing some of the parameters normally included with the response of a smart meter. Is that a problem, or does Domoticz ignore those?

Another difference that might be a problem is that my output also includes the unit (kWh) instead of just the number and the numbers are a bit different than a normal P1 smart meter. Can I adjust those with the commands I'm running to get the output or do I need to modify them somewhere?

I took a look at the thread you linked and it seems the lines code I have right now is already readable (if I'm understanding it correctly).
phenix56
Posts: 31
Joined: Sunday 10 October 2021 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Converting output to Domoticz smart meter

Post by phenix56 »

After some more digging, it seems that my converter gives the outputs in another format than Domoticz tried to read it. I downloaded the source code and re-built Domoticz with the values changed according to my output, but Domoticz still seems to be unable to read it correctly. This time, it even refuses to show any device in the 'devices' tab, instead of a device with wrong values.

How can I get this working?
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Converting output to Domoticz smart meter

Post by FireWizard »

Hello @phenix,

I can try to help you, but a few questions first.

1. What kind of device is it? Yes , a electricity meter, but how do you read it?
Is the interface RS-232C or USB.
2. What are the communication parameters?
3, Are you familiar with Node-RED?
4. What kind of device is used for Domoticz? Raspberry Pi?

Let me know.

Regards and Happy New Year.
phenix56
Posts: 31
Joined: Sunday 10 October 2021 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Converting output to Domoticz smart meter

Post by phenix56 »

Hi FireWizzard,

1) I have a Iskra digital meter which I can readout using a IR-USB converter. I put the commands sent earlier (see above) in a script and schedule it via crontab. When I execute the script, it produces the output as sent above in the /dev/ttyUSB0 interface.
2) Not sure what you mean with this one. Do you mean how I am communicating with the IR reader?
3) Not really, outside of the solar panel project you helped me with earlier
4) I am currently testing on a VMware VM running Ubuntu Server 22.04 with USB-pass though enabled, but once everything is working I an planning to move it to a Raspberry Pi 4.


I wish you a Happy New Year too!

Rg,

Phenix
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Converting output to Domoticz smart meter

Post by FireWizard »

Hi @phenix56

Does your IR-USB converter produce the earlier posted data or do you get that after your data passed your script?

Do you have Node Red still running?

Do you only want to see the OBIS references 1.8.0 , 1.8.1, 1.8.2, resp 2.8.0, 2.8.1 and 2.8.2?
Or is there more data you are interested in?

We will have a look next year :D

Regards
phenix56
Posts: 31
Joined: Sunday 10 October 2021 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Converting output to Domoticz smart meter

Post by phenix56 »

Hi FireWizzard,

The IR-USB converter does not produce any data without the commands in my script 'asking' the Iskra to send the data.

I do not have Node Red running on the VM I am testing this on, but I can off course install it.

All I am really interested right now is in the total consumed and total return, but it would be nice to have the other available OBIS references logged as well in case I want to do something with it in the future.

Rg,

Phenix
gordonb3
Posts: 111
Joined: Saturday 31 March 2018 22:24
Target OS: Linux
Domoticz version: Custom
Location: Delft, NL
Contact:

Re: Converting output to Domoticz smart meter

Post by gordonb3 »

Lose the '/?!' line, and the '000' line, and the 'FF(0000)' line.
Next, delete the '*255' part in the lines and replace [space] with a '*'

i.e. your resulting message should look like this:

Code: Select all

/ISk5MT171-0133


0-0:C.1.0(47827401)

1-0:0.0.0(47827401)

1-0:0.2.0(V1.0)

1-0:1.8.0(035745*kWh)

1-0:1.8.1(019928*kWh)

1-0:1.8.2(015817*kWh)

1-0:2.8.0(030550*kWh)

1-0:2.8.1(023577*kWh)

1-0:2.8.2(006972*kWh)


!
For cleanness get rid of the empty lines but the smartmeter module should not trip over them except likely for generating a one time warning that the message appears to be manipulated.

Bash example:

Code: Select all

cat <rawmessage> | sed -e "/\/?\!/d" -e "/^000/d" -e "/^FF/d" -e "s/\*255//g" -e "s/ *$//g" -e "s/ /*/" -e "s/\r//g" -e "/^\s*$/d"
phenix56
Posts: 31
Joined: Sunday 10 October 2021 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Converting output to Domoticz smart meter

Post by phenix56 »

Looks like I have to temporarily store the output somewhere else, in order for Domoticz to not pick up the wrong signal, right?

I tried your example command, replacing the <rawmessage> with /dev/ttyUSB0 (which is where the output gets stored). Running it before/after my script 'dumps' the original output does not do anything, and leaving it running while the output is being 'dumped' results in parts of the output being stored in /dev/ttyUSB0, and parts being stored to the terminal where the command is running, making the whole output unreadable :(. Just tobe sure, I checked if Domoticz could read anything, and the answer is no.

Is there something I need to change or is this supposed to work?
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Converting output to Domoticz smart meter

Post by FireWizard »

Hello @phenix56,

Happy New Year

You should first decide which way you want to go. Is it with Node-RED or do you want to continue with your script and/or the example from @gordonb3.
If it is NR, I can try to support you. If you continue with your script perhaps @gordonb3 can help you.

Regards
phenix56
Posts: 31
Joined: Sunday 10 October 2021 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Converting output to Domoticz smart meter

Post by phenix56 »

Hi FireWizzard,

I think Node-RED would be the 'cleanest' since I already have it running on my Raspberry Pi, especially if you think we can get it working.

Can I PM you to discuss it further (in Dutch)?
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Converting output to Domoticz smart meter

Post by FireWizard »

Yes you can send me a PM.
Jieffe
Posts: 18
Joined: Wednesday 07 April 2021 19:33
Target OS: Linux
Domoticz version: 2023.2
Location: Belgium
Contact:

Re: Converting output to Domoticz smart meter

Post by Jieffe »

I also have an Iskra meter for my solar panels. There is an ESP8266 program to read the IR interface of an Iskra ME162 here : https://github.com/wdoekes/pe32me162ir_pub.

You need to adapt the code to communicate with Domoticz or use Node-Red to translate the MQTT output but it is feasible.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Converting output to Domoticz smart meter

Post by waltervl »

Perhaps this approach with python will also work viewtopic.php?t=5270
You can also have the batch file that is reading the file from USB make API calls directly to a virtual P1 meter (manually created).
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest