Closed andrejsoucek closed 1 year ago
Ok I have some progress, I've played with the Serial on Arduino and discovered debug logs in Z2M saying that it received messages but they didn't get processed because the device joined as a CC2530 router. I stopped Z2M, deleted the backup json, started again, now the device looks like a DIY device according to PTVO Expert settings, I imported the external converter, everything looks ok, the device is "Supported" in Z2M, exposes linkquality and action. But in logs I only see MQTT publish: topic 'zigbee2mqtt/[name]/action', payload '73,110,112,117,116,32,86,111,108,116,97,103,101,32,61,32,48,46,48,48,13,10,87,105,110,100,32,83,112,101,101,100,32,61,32,48,46,48,48,13,10,72,105'
Ok, looks like I was sending some unsupported characters. Changed the message to be a json: {"1": 0}
which is now visible in logs.
Info 2023-09-05 01:10:41MQTT publish: topic 'zigbee2mqtt/[name]', payload '{"action":"{\"1\": 0}","linkquality":148}'
Info 2023-09-05 01:10:41MQTT publish: topic 'zigbee2mqtt/[name]', payload '{"action":"","linkquality":148}'
Info 2023-09-05 01:10:41MQTT publish: topic 'zigbee2mqtt/[name]/action', payload '{"1": 0}'
But why it gets reset to empty immediately after it is received? How do I use the value in HA?
Edit: I removed automatically created HA entity where the value was shown for miliseconds and then went back to empty. Instead I created an mqtt sensor:
mqtt:
sensor:
- state_topic: "zigbee2mqtt/meteo/action"
name: "Current Wind"
value_template: '{{ value_json["1"] }}'
unit_of_measurement: "kt"
Is the value reset intended, tho? This looks more like a workaround.
@andrejsoucek It reset because a new data packet may appear immediately after it, but it may have the same content.
@andrejsoucek It reset because a new data packet may appear immediately after it, but it may have the same content.
how do I prevent it? or where would that packet come from?
@andrejsoucek You can create a custom converter for Z2M and process data from a device as you want.
I ended up with this converter for now:https://github.com/andrejsoucek/zigbee-weather-station/commit/9500e7463f8a445be9296826ff449d608e224213 which fixed merged payloads (2 serial prints actually appeared as one payload, see below) but don't know how to skip the empty action
Arduino code:
Serial.print("{\"1\":" + value1 + "}");
Serial.print("{\"2\":" + value2 + "}");
PTVO generated converter payload:
{ 1: "value1" }{ 2: "value2" } // only first json gets processed, second one with key 2 is ignored
Edited converter payload:
{ 1: "value1", 2: "value2" } // correctly returns both values in one object
EDIT: I completely changed the converter for z2m and now it exposes the values as numeric, not JSON. MQTT entity discovery in HA works great. Changes can be seen here https://github.com/andrejsoucek/zigbee-weather-station/commit/0cec6f9cf065793179e9e4f4abbfa2ed09b0587b BTW the empty action was caused by this: https://github.com/Koenkk/zigbee2mqtt/blob/f224ef7b7c9ba1cc6819c3b7bf84119d7ce5ec9b/lib/extension/homeassistant.ts#L1021
Closing this issue.
Hello, sorry for posting a question to issues, however I can't figure out following problem with Arduino and CC2530+CC2591. In PTVO, I set Output 1 to P02, UART, 9600 baud, Packet end None, Byte 239. I connected CC2530 P02 to Arduino pin 5, P03 to pin 6 and then use SoftwareSerial library:
The CC2530 is connected to my network, recognized by zigbee2mqtt, exposes only linkquality and I can't transfer any data in any direction. I tried ss.println('1'); and nothing happens in mqtt explorer, other way I tried to publish
with error: No converter available.
What am I doing wrong? Am I missing something?
I am willing to pay to anyone who can help me sorting this out successfully.