Receiving MQTT messages from Node Red scraper

Hi,
New to HA, have Domoticz running but in progress of moving over.
In Domoticz I have a Node Red Flow that scrapes data from my AP Systems management tool.
Data include:
Power per solar panel
Inverter Frequency, Temperature Voltage
Lifetime power Generation
Last System power
Generation of current day
Petrol CO2 offset
Trees CO2 offset
Factory CO2 offset
Node Red flow is connected to HA so messages are received, and here I get stuck in HA.
In Domoticz each variable has been linked to a device i.e. power solar panel 1 is in Domoticz IDX4932, MQTT sends the values as:

switch (msg.payload[0]) {

    case "inverter ID#": //Inverter 1

    msg1.payload = {"command":"udevice","idx":4932,"nvalue":0,"svalue":(msg.payload[1] + ";0")}; //Current Power A

    msg2.payload = {"command":"udevice","idx":4944,"nvalue":0,"svalue":(msg.payload[2])}; //Voltage A

    msg3.payload = {"command":"udevice","idx":4933,"nvalue":0,"svalue":(msg.payload[3] + ";0")}; //Current Power B

    msg4.payload = {"command":"udevice","idx":4945,"nvalue":0,"svalue":(msg.payload[4])}; //Voltage B

    msg5.payload = {"command":"udevice","idx":4956,"nvalue":0,"svalue":(msg.payload[5])}; //Frequency

    msg6.payload = {"command":"udevice","idx":4962,"nvalue":0,"svalue":(msg.payload[6])}; //Temperature

Matching the value of inverter to device in Domoticz.
My question is how do I get/create devices in HA to receive MQTT messages. I have installed the MQTT broker in HA, that is working fine, as it receives the MQTT messages from my Daikin control units (Faikin). These were auto discovered by HA
In MQTT I have switched on “Listen to a Topic” which shows to Node Red flow.
Format is JSON Content. But I do not see anything related to the Solarpanels.
What do I need to do to get the panel details and overall details available in HA?

Many thanks for the support.

Bernard

MQTT device integrations either need to send discovery information (as is presumably happening with your Daikin), or you set them up manually using MQTT Sensor entries.

From the code you posted it’s not clear if you’re sending those messages with the same topic or separate ones. It’s easier in HA if each entity has a separate topic. Then to set them up manually, for example:

mqtt:
  - sensor:
      name: "Current Power A"
      unique_id: current_power_a
      state_topic: "your/topic/for/power/a"
      value_template: "{{ value_json.svalue }}"

As you can see, if they all share the same topic, it’s more cumbersome to only update current_power_a if idx is 4932.

Also, your current svalue has “;0” on the end - not sure what this is for (is it a Domoticz thing?). For HA, you will want just the raw value (and use unit_of_measurement).

Thanks, I will check and fiddle with this.
Hopeful now that I can build a dashboard with the 12 panels, 6 inverters and general data provided by AP Systems management box.

I have been playing with this, and created the devices in the config file. Per inverter these items:

- sensor:
      name: "Zonnepaneel 1 Power"
      unique_id: idx4932 Current Power A
      state_topic: "AP_Systems"
      value_template: "{{ value_json.svalue }}"
  - sensor:
      name: "Zonnepaneel 1 Voltage"
      unique_id: idx4944
      state_topic: "AP_Systems"
      value_template: "{{ value_json.svalue }}"
  - sensor:
      name: "Zonnepaneel 2 Power"
      unique_id: idx4933
      state_topic: "AP_Systems"
      value_template: "{{ value_json.svalue }}"
  - sensor:
      name: "Zonnepaneel 2 Voltage"
      unique_id: idx4945
      state_topic: "AP_Systems"
      value_template: "{{ value_json.svalue }}"
  - sensor:
      name: "Omvormer 1 Frequency"
      unique_id: idx4956
      state_topic: "AP_Systems"
      value_template: "{{ value_json.svalue }}"
  - sensor:
      name: "Omvormer 1 Temperature"
      unique_id: idx4962
      state_topic: "AP_Systems"
      value_template: "{{ value_json.svalue }}"

Where the unique ID is send in the MQTT message as idx####
All is published under 1 topic “AP_systems”. Would not know how to change my Node RED flow into a flow where each parameter for each converter is published with it’s own topic.
Result today is that I get all published values under 1 sensor.
Can some one help me in getting sensors populated with the correct value out of this AP_Systems topic?
Thanks for the support.

I looked further through the help pages and found a list of sensor types that could be used. I did amend the YAML to get an error message:
"The system cannot restart because the configuration is not valid: Invalid config for [mqtt]: [power] is an invalid option for [mqtt]. Check: mqtt->mqtt->0->power. (See /config/configuration.yaml, line 26). "
So under MQTT only Sensor is allowed and not the other type like power, temperature, voltage and frequency?
here the YAML:

### Omvormer 1 - ### - Zonnepaneel 1 en 2
  - power:
      name: Zonnepaneel 1 Power
      unique_id: idx4932
      state_topic: AP_Systems
      value_template: "{{ value_json.svalue }}"
      area: dakkapel
      manufactorer: AP Systems
  - voltage:
      name: Zonnepaneel 1 Voltage
      unique_id: idx4944
      state_topic: AP_Systems
      value_template: "{{ value_json.svalue }}"
      area: dakkapel
      manufactorer: AP Systems
  - power:
      name: Zonnepaneel 2 Power
      unique_id: idx4933
      state_topic: AP_Systems
      value_template: "{{ value_json.svalue }}"
      area: dakkapel
      manufactorer: AP Systems
  - voltage:
      name: Zonnepaneel 2 Voltage
      unique_id: idx4945
      state_topic: AP_Systems
      value_template: "{{ value_json.svalue }}"
      area: dakkapel
      manufactorer: AP Systems
  - frequency:
      name: Omvormer 1 Frequency
      unique_id: idx4956
      state_topic: AP_Systems
      value_template: "{{ value_json.svalue }}"
      area: dakkapel
      manufactorer: AP Systems
  - temperature:
      name: Omvormer 1 Temperature
      unique_id: idx4962
      state_topic: AP_Systems
      value_template: "{{ value_json.svalue }}"
      area: dakkapel
      manufactorer: AP Systems

Next to this I tried to add the area an manufactorer as well so I do not have to set it for each sensor in the overview again error:

ERROR (MainThread) [homeassistant.components.mqtt.mixins] extra keys not allowed @ data[‘area’] for manually configured MQTT sensor item, in /config/configuration.yaml, line 28 Got {‘name’: ‘Zonnepaneel 1 Power’, ‘unique_id’: ‘idx4932’, ‘state_topic’: ‘AP_Systems’, ‘value_template’: ‘{{ value_json.svalue }}’, ‘area’: ‘dakkapel’, ‘manufactorer’: ‘AP Systems’}

Does someone know what I do wrong? Just want something very simple, input feed from MQTT into devices in HA with filled by picking up the uniique ID.

Thanks for the support

Hi,

Is there anyone that can assist and point me in the right direction? I do not understand the logic of HA devices. Have a MQTT feed which is sending information with unique ID’s into HA. AS per posts above HA does not pick up and get values send over MQTT assigned to the devices…
I know not a HA issue but a human error on my part :face_with_open_eyes_and_hand_over_mouth:

Thanks!