syssi / esphome-soyosource-gtn-virtual-meter

ESPHome component to simulate the current clamp to control the Soyosource GTN1200 limiter
Apache License 2.0
80 stars 23 forks source link

How should a mqtt message look like? #194

Closed SuniramF closed 2 weeks ago

SuniramF commented 2 weeks ago

Hi Sissy, I used this esp32-limiter-example.yaml for my setup. This is working if i use HA to send values via node-red.

I would like to use a raspberry pi with mosquitto and node-red to have controll of al the power units. In stead of Home assistent. So i build DSMR (Clever power meter) with esphome that sends mqtt message of the used power. =>working 3 epever chargers (for my home-battery) with mqtt to mosquitto => working

I have a short question. I am trying to send a "power demand" with mqtt with my node-red node via mosquito This doesn't work as i expected. If a messages "3" is send then i get an error in my esp32 logging: [20:10:02][W][mqtt_subscribe.sensor:018]: Can't convert '"3"' to number! So, mqtt messages arive at the esp, communication seems ok

Changing the mqtt message to 3 (so without the quotes) doesn't show up in the esp logging, and connected to the gtn1000 the demand power is not showing in the display. (this working fine with a message to Home assistant)

So question is: How should the mqtt messages look like. ? Or do i have to delete part in the Yaml that connect to home assistant?

Thanks in advance for your time?

Freek from the Netherlands Answer can be in German :-)

sensor:

syssi commented 2 weeks ago

I have a short question. I am trying to send a "power demand" with mqtt with my node-red node via mosquito This doesn't work as i expected. If a messages "3" is send then i get an error in my esp32 logging: [20:10:02][W][mqtt_subscribe.sensor:018]: Can't convert '"3"' to number!

Could you be more specific here? Could you provide the explicit payload including the addressed topic?

SuniramF commented 2 weeks ago

Wow you are fast.

So message is send to mosquitto and recieved back by a subscription in node red: This is the message that is receive back in node red with a debug node21. 11-11-2024, 20:57:22node: debug 21 fromsolarsched/gtn1/gtpower : msg.payload : number 3

SuniramF commented 2 weeks ago

Or in node-red code

[
    {
        "id": "baf30df05a8a4031",
        "type": "debug",
        "z": "558548c5fd0414db",
        "name": "debug 21",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 2380,
        "y": 680,
        "wires": []
    },
    {
        "id": "8ca2d993d595e758",
        "type": "mqtt out",
        "z": "558548c5fd0414db",
        "name": "",
        "topic": "fromsolarsched/gtn1/gtpower",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "b8f95fc026575790",
        "x": 2330,
        "y": 620,
        "wires": []
    },
    {
        "id": "cd77e066986110aa",
        "type": "inject",
        "z": "558548c5fd0414db",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "3",
        "payloadType": "str",
        "x": 2010,
        "y": 620,
        "wires": [
            [
                "8ca2d993d595e758"
            ]
        ]
    },
    {
        "id": "598fdd6fcd89a7d0",
        "type": "mqtt in",
        "z": "558548c5fd0414db",
        "name": "",
        "topic": "fromsolarsched/gtn1/gtpower",
        "qos": "0",
        "datatype": "auto-detect",
        "broker": "b8f95fc026575790",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 2060,
        "y": 680,
        "wires": [
            [
                "baf30df05a8a4031"
            ]
        ]
    },
    {
        "id": "b8f95fc026575790",
        "type": "mqtt-broker",
        "name": "max docker mosquitto",
        "broker": "172.16.0.10",
        "port": "1883",
        "clientid": "nodered",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": false,
        "autoUnsubscribe": true,
        "birthTopic": "bat1balance/cel2",
        "birthQos": "0",
        "birthRetain": "true",
        "birthPayload": "1",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
syssi commented 2 weeks ago

Could you use mosquitto_sub to dump the traffic? My setup is pretty similar:

This is the MQTT traffic of my smartmeter (published by ESPHome):

$ mosquitto_sub -v -t 'basement-smartmeter/sensor/basement-smartmeter-firstfloor_instantaneous_power/state'
basement-smartmeter/sensor/basement-smartmeter-firstfloor_instantaneous_power/state 342.77
basement-smartmeter/sensor/basement-smartmeter-firstfloor_instantaneous_power/state 338.80
basement-smartmeter/sensor/basement-smartmeter-firstfloor_instantaneous_power/state 338.05
basement-smartmeter/sensor/basement-smartmeter-firstfloor_instantaneous_power/state 338.37

And this is the sensor to consume the measurement and pass it to the limiter at the ESPHome node driving the Soyosource:

sensor:
  - platform: mqtt_subscribe
    id: powermeter_firstfloor
    internal: true
    name: "${inverter0} smartmeter instantaneous power"
    topic: "basement-smartmeter/sensor/basement-smartmeter-firstfloor_instantaneous_power/state"
    accuracy_decimals: 2
    unit_of_measurement: W
    device_class: power
    filters:
      - throttle: 15s

Could you try to pass a float 3.0 as payload to the topic instead of 3 or "3"?

SuniramF commented 2 weeks ago

that was easy : -) 30.00 did the trick [21:37:21][D][sensor:094]: 'soyosource-gtn1000-mqtt-test instantaneous power consumption': Sending state 30.00000 W with 2 decimals of accuracy [21:37:21][D][soyosource_virtual_meter:097]: 'firstfloor_inverter': Using the new method to calculate the power demand: 30 0 [21:37:21][D][soyosource_virtual_meter:020]: 'firstfloor_inverter': New calculated demand: 20 / last demand: 0 [21:37:21][D][soyosource_virtual_meter:073]: 'firstfloor_inverter': Setting the limiter to 0 watts per inverter (0 in total)

danke schön Sebastian !

syssi commented 2 weeks ago

Sehr gerne! Schöne Grüße in die Niederlande!