Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I don't seem to receive consumption data, only configuration data #7

Closed
smartathome opened this issue Sep 27, 2023 · 6 comments
Closed

Comments

@smartathome
Copy link

smartathome commented Sep 27, 2023

Hi,

I've setup the code but the JSON received through MQTT only shows configuration. In the logging, I see that certain MQTT messages don't seem to be sent.

user@server:/opt/dsmr2mqtt $ python3 dsmr-mqtt.py dsmr-mqtt INFO: FUNCTION:<module> LINE:70: Starting /opt/dsmr2mqtt/dsmr-mqtt.py; version = 3.0.0 dsmr-mqtt.mqtt.mqtt INFO: FUNCTION:__init__ LINE:103: >> paho-mqtt version = 1.5.1 dsmr-mqtt.mqtt.mqtt INFO: FUNCTION:__init__ LINE:117: MQTT Client ID = mqtt-dsmr dsmr-mqtt.P1_serial DEBUG: FUNCTION:__init__ LINE:51: >> dsmr-mqtt.P1_serial DEBUG: FUNCTION:__init__ LINE:73: serial /dev/ttyUSB0 opened dsmr-mqtt.P1_parser DEBUG: FUNCTION:__init__ LINE:50: >> dsmr-mqtt.P1_parser DEBUG: FUNCTION:__init__ LINE:62: NROF = 1 dsmr-mqtt.hadiscovery DEBUG: FUNCTION:__init__ LINE:49: >> dsmr-mqtt DEBUG: FUNCTION:<module> LINE:174: __main__: >> dsmr-mqtt DEBUG: FUNCTION:main LINE:138: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:will_set LINE:425: >> dsmr-mqtt.mqtt.mqtt INFO: FUNCTION:run LINE:517: Broker = 192.168.0.5>> dsmr-mqtt.P1_parser DEBUG: FUNCTION:run LINE:211: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__internet_on LINE:222: >> dsmr-mqtt.hadiscovery DEBUG: FUNCTION:run LINE:128: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=homeassistant/sensor/dsmr/dsmr-device/config; MESSAGE={"name":"Status","unique_id":"dsmr-device","state_topic":"dsmr/status","icon":"mdi:home-automation","device":{"name":"HA dsmr reader","sw_version":"3.0.0","model":"P1 USB/dsmr-mqtt","manufacturer":"hansij66 @github.com","identifiers":["dsmr"]}} dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=homeassistant/sensor/dsmr/p_consumed/config; MESSAGE={"unique_id":"p_consumed","state_topic":"dsmr/el","name":"Total power usage [W]","unit_of_measurement":"W","value_template":"{{value_json.p_consumed}}","device_class":"power","icon":"mdi:gauge","device":{"identifiers":["dsmr"]}} dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__internet_on LINE:229: Internet connectivity to MQTT broker 192.168.0.5 at port 1883 available dsmr-mqtt.mqtt.mqtt INFO: FUNCTION:run LINE:575: Start mqtt loop... dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:set_status LINE:408: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__set_status LINE:391: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=dsmr/status; MESSAGE=online dsmr-mqtt.P1_serial DEBUG: FUNCTION:run LINE:198: >> dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.P1_serial DEBUG: FUNCTION:__read_serial LINE:152: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=homeassistant/sensor/dsmr/p_generated/config; MESSAGE={"unique_id":"p_generated","state_topic":"dsmr/el","name":"Total power generation [W]","unit_of_measurement":"W","value_template":"{{value_json.p_generated}}","device_class":"power","icon":"mdi:gauge","device":{"identifiers":["dsmr"]}} dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=dsmr/sw-version; MESSAGE=main=3.0.0; mqtt=2.0.0 dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:run LINE:587: Disconnect TIMER = 0 dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=homeassistant/sensor/dsmr/gas_consumed/config; MESSAGE={"unique_id":"gas_consumed","state_topic":"dsmr/gas","name":"gas consumption [m\u00b3]","unit_of_measurement":"m\u00b3","value_template":"{{value_json.gas_consumed|float/1000|round(0)}}","device_class":"gas","state_class":"total","icon":"mdi:counter","device":{"identifiers":["dsmr"]}} dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=homeassistant/sensor/dsmr/el_consumed/config; MESSAGE={"unique_id":"el_consumed","state_topic":"dsmr/el","name":"EL consumed [Wh]","unit_of_measurement":"Wh","value_template":"{{value_json.el_consumed}}","device_class":"energy","state_class":"total","icon":"mdi:counter","device":{"identifiers":["dsmr"]}} dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=homeassistant/sensor/dsmr/el_returned/config; MESSAGE={"unique_id":"el_returned","state_topic":"dsmr/el","name":"EL returned [Wh]","unit_of_measurement":"Wh","value_template":"{{value_json.el_returned}}","device_class":"energy","state_class":"total","icon":"mdi:counter","device":{"identifiers":["dsmr"]}} dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=homeassistant/sensor/dsmr/V1/config; MESSAGE={"unique_id":"V1","state_topic":"dsmr/el","name":"Voltage L1 [V]","unit_of_measurement":"V","value_template":"{{value_json.V1}}","device_class":"voltage","icon":"mdi:gauge","device":{"identifiers":["dsmr"]}} dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=homeassistant/sensor/dsmr/V2/config; MESSAGE={"unique_id":"V2","state_topic":"dsmr/el","name":"Voltage L2 [V]","unit_of_measurement":"V","value_template":"{{value_json.V2}}","device_class":"voltage","icon":"mdi:gauge","device":{"identifiers":["dsmr"]}} dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=homeassistant/sensor/dsmr/V3/config; MESSAGE={"unique_id":"V3","state_topic":"dsmr/el","name":"Voltage L3 [V]","unit_of_measurement":"V","value_template":"{{value_json.V3}}","device_class":"voltage","icon":"mdi:gauge","device":{"identifiers":["dsmr"]}} dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__on_connect LINE:262: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__on_connect LINE:264: Connected: userdata=None; flags={'session present': 0}; rc=Success: Connection Accepted. dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__set_connected_flag LINE:237: >> flag=True; current __connected_flag=False dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__set_status LINE:391: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=dsmr/status; MESSAGE=online

Am I doing something wrong?

@hansij66
Copy link
Owner

hansij66 commented Sep 27, 2023 via email

@smartathome
Copy link
Author

smartathome commented Sep 27, 2023

Thanks for getting back to me so quickly. I'm from Belgium and have a Sagemcom meter.
USB should be fine:
[ 8.861708] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0

I've put the system into simulation mode and disabled discovery. I do see DSMR data appearing on the command line but still some connections seem unsuccesful. In the MQTT explorer I see the following config messages. But I do not see consumption data appearing.

Logging from dsmr-mqtt.py:
user@server:/opt/dsmr2mqtt $ python3 dsmr-mqtt.py dsmr-mqtt INFO: FUNCTION:<module> LINE:70: Starting /opt/dsmr2mqtt/dsmr-mqtt.py; version = 3.0.0 dsmr-mqtt.mqtt.mqtt INFO: FUNCTION:__init__ LINE:103: >> paho-mqtt version = 1.5.1 dsmr-mqtt.mqtt.mqtt INFO: FUNCTION:__init__ LINE:117: MQTT Client ID = mqtt-dsmr-test dsmr-mqtt.P1_serial DEBUG: FUNCTION:__init__ LINE:51: >> dsmr-mqtt.P1_parser DEBUG: FUNCTION:__init__ LINE:50: >> dsmr-mqtt.P1_parser DEBUG: FUNCTION:__init__ LINE:62: NROF = 1 dsmr-mqtt.hadiscovery DEBUG: FUNCTION:__init__ LINE:49: >> dsmr-mqtt DEBUG: FUNCTION:<module> LINE:174: __main__: >> dsmr-mqtt DEBUG: FUNCTION:main LINE:138: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:will_set LINE:425: >> dsmr-mqtt.mqtt.mqtt INFO: FUNCTION:run LINE:517: Broker = 192.168.0.5>> dsmr-mqtt.P1_parser DEBUG: FUNCTION:run LINE:211: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__internet_on LINE:222: >> dsmr-mqtt.hadiscovery DEBUG: FUNCTION:run LINE:128: >> dsmr-mqtt.P1_serial DEBUG: FUNCTION:run LINE:198: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__internet_on LINE:229: Internet connectivity to MQTT broker 192.168.0.5 at port 1883 available dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:set_status LINE:408: >> dsmr-mqtt.P1_serial DEBUG: FUNCTION:__read_serial LINE:152: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__set_status LINE:391: >> dsmr-mqtt.mqtt.mqtt INFO: FUNCTION:run LINE:575: Start mqtt loop... dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=dsmr/status; MESSAGE=online dsmr-mqtt.P1_parser DEBUG: FUNCTION:__decode_telegrams LINE:184: >> dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:run LINE:587: Disconnect TIMER = 0 dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=dsmr/system; MESSAGE={"dsmr_version":50,"timestamp":1695839263} dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=dsmr/sw-version; MESSAGE=main=3.0.0; mqtt=2.0.0 dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=dsmr/el; MESSAGE={"P1_consumed":677.0,"P1_generated":0.0,"P2_consumed":56.0,"P2_generated":0.0,"P3_consumed":132.0,"P3_generated":0.0,"V1":231.0,"V1_sags":5,"V1_swells":0,"V2":234.0,"V2_sags":5,"V2_swells":0,"V3":233.0,"V3_sags":4,"V3_swells":0,"el_consumed":23679674.0,"el_returned":21097674.0,"long_power_failures":12,"p_consumed":866.0,"p_generated":0.0,"power_failures":1373,"serial":"33363137","timestamp":1695839263} dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.mqtt.mqtt WARNING: FUNCTION:do_publish LINE:451: MQTT publish was not successfull, rc = 4: The client is not currently connected. dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=dsmr/gas; MESSAGE={"gas_consumed":10142194.0,"serial":"33313137","timestamp":1695839263} dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__on_connect LINE:262: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__on_connect LINE:264: Connected: userdata=None; flags={'session present': 0}; rc=Success: Connection Accepted. dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__set_connected_flag LINE:237: >> flag=True; current __connected_flag=False dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:__set_status LINE:391: >> dsmr-mqtt.mqtt.mqtt DEBUG: FUNCTION:do_publish LINE:444: >> TOPIC=dsmr/status; MESSAGE=online ^Cdsmr-mqtt DEBUG: FUNCTION:exit_gracefully LINE:128: Signal 2: >> dsmr-mqtt INFO: FUNCTION:exit_gracefully LINE:134: << ^Z [1]+ Stopped python3 dsmr-mqtt.py

Logging from MQTT explorer:
Message 28 received on homeassistant/sensor/dsmr/gas_consumed/config at 8:12 PM: { "unique_id": "gas_consumed", "state_topic": "dsmr/gas", "name": "gas consumption [m³]", "unit_of_measurement": "m³", "value_template": "{{value_json.gas_consumed|float/1000|round(0)}}", "device_class": "gas", "state_class": "total", "icon": "mdi:counter", "device": { "identifiers": [ "dsmr" ] } } QoS: 0 - Retain: true Message 27 received on homeassistant/sensor/dsmr/p_generated/config at 8:12 PM: { "unique_id": "p_generated", "state_topic": "dsmr/el", "name": "Total power generation [W]", "unit_of_measurement": "W", "value_template": "{{value_json.p_generated}}", "device_class": "power", "icon": "mdi:gauge", "device": { "identifiers": [ "dsmr" ] } } QoS: 0 - Retain: true Message 26 received on homeassistant/sensor/dsmr/p_consumed/config at 8:12 PM: { "unique_id": "p_consumed", "state_topic": "dsmr/el", "name": "Total power usage [W]", "unit_of_measurement": "W", "value_template": "{{value_json.p_consumed}}", "device_class": "power", "icon": "mdi:gauge", "device": { "identifiers": [ "dsmr" ] } } QoS: 0 - Retain: true Message 25 received on homeassistant/sensor/dsmr/dsmr-device/config at 8:12 PM: { "name": "Status", "unique_id": "dsmr-device", "state_topic": "dsmr/status", "icon": "mdi:home-automation", "device": { "name": "HA dsmr reader", "sw_version": "3.0.0", "model": "P1 USB/dsmr-mqtt", "manufacturer": "hansij66 @github.com", "identifiers": [ "dsmr" ] } }

@hansij66
Copy link
Owner

hansij66 commented Sep 27, 2023 via email

@smartathome
Copy link
Author

It was my stupid mistake, the P1 port was not opened on the meter itself. I should have checked first on the command line before starting the script.

How to test:
sudo apt install python3-serial python3-crcmod python3-tabulate
sudo chmod o+rw /dev/ttyUSB0

user@server:~$ python3 -m serial.tools.miniterm /dev/ttyUSB0 115200 --xonxoff
--- Miniterm on /dev/ttyUSB0 115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
925*m3)
!CE4E
/FLU5\253xxxxxx_A

0-0:96.1.4(xxxxx)
0-0:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxx)
0-0:1.0.0(210204163628W)
1-0:1.8.1(000439.094kWh)
1-0:1.8.2(000435.292kWh)

@hansij66 hansij66 closed this as completed Oct 4, 2023
@hansij66
Copy link
Owner

hansij66 commented Oct 4, 2023

Issue resolved

@hansij66 hansij66 reopened this Oct 4, 2023
@hansij66
Copy link
Owner

hansij66 commented Oct 4, 2023

Linked to unrelated patches Smartathome patch 1 (PR #8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants