Missing sensor in home assistant integration
-
Hi Guys,
I'm desperately looking into your support. My 1st "mysensor" does not want to integrate into HA.
What I have done so far:- Created serial gateway with standard gateway sketch from arduino examples
dmesg provides:
[ 2.343789] usb 1-1.4: Product: TI CC2531 USB CDC [ 2.419871] usbserial: USB Serial support registered for ch341-uart [ 2.425327] usb 1-1.3: ch341-uart converter now attached to ttyUSB0
- Created sensor with fake temperature reporting (sketch below)
- Added mysensor integration to HA (Home Assistant Core Version core-2021.3.0) with following parameter Protocol 2.3.2, empty line for persistence file, speed set to 115200 and /dev/USB0 for port as follow
Results: Under Integration I've got a "mysensor" icon with "/dev/ttyUSB0"
And in the core log I can see:
2021-05-01 20:53:17 DEBUG (SyncWorker_7) [mysensors.persistence] Saving sensors to persistence file /config/mysensors_7d7c3a66687852fd3cb1b682191327ed.json
Persistence file consists of:
{ "0": { "sensor_id": 0, "children": {}, "type": 18, "sketch_name": null, "sketch_version": null, "battery_level": 0, "protocol_version": "2.3.2", "heartbeat": 0 } }
Now I''m starting the sensor with following debug output:
__ __ ____ | \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___ | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __| | | | | |_| |___| | __/ | | \__ \ _ | | \__ \ |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/ |___/ 2.3.2 16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2 26 TSM:INIT 28 TSF:WUR:MS=0 34 TSM:INIT:TSP OK 36 TSF:SID:OK,ID=100 38 TSM:FPAR 43 ?TSF:MSG:SEND,100-100-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 1033 TSF:MSG:READ,0-0-100,s=255,c=3,t=8,pt=1,l=1,sg=0:0 1038 TSF:MSG:FPAR OK,ID=0,D=1 2050 TSM:FPAR:OK 2051 TSM:ID 2052 TSM:ID:OK 2054 TSM:UPL 2091 !TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1 4099 TSM:UPL 4135 !TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=1,st=NACK:1 6144 TSM:UPL 6180 !TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=2,st=NACK:1 8188 TSM:UPL 8192 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=3,st=OK:1 8201 TSF:MSG:READ,0-0-100,s=255,c=3,t=25,pt=1,l=1,sg=0:1 8206 TSF:MSG:PONG RECV,HP=1 8209 TSM:UPL:OK 8210 TSM:READY:ID=100,PAR=0,DIS=1 8215 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 8222 TSF:MSG:READ,0-0-100,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 8231 TSF:MSG:SEND,100-100-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2 8241 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0 8257 TSF:MSG:READ,0-0-100,s=255,c=3,t=6,pt=0,l=1,sg=0:M Presenting Sensor 8267 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=11,pt=0,l=10,sg=0,ft=0,st=OK:TestSensor 8276 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0 8285 TSF:MSG:SEND,100-100-0-0,s=1,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=OK: 8291 MCO:REG:REQ 8295 TSF:MSG:SEND,100-100-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 8301 TSF:MSG:READ,0-0-100,s=255,c=3,t=27,pt=1,l=1,sg=0:1 8306 MCO:PIM:NODE REG=1 8309 MCO:BGN:STP Starting Sensor 9311 MCO:BGN:INIT OK,TSP=1 Sending initial value 9316 TSF:MSG:SEND,100-100-0-0,s=1,c=1,t=43,pt=0,l=11,sg=0,ft=0,st=OK:Custom_Volt 9325 TSF:MSG:SEND,100-100-0-0,s=1,c=1,t=37,pt=0,l=3,sg=0,ft=0,st=OK:0.0 Requesting initial value from controller 9333 TSF:MSG:SEND,100-100-0-0,s=1,c=2,t=37,pt=0,l=0,sg=0,ft=0,st=OK: 9345 TSF:MSG:READ,0-0-100,s=1,c=1,t=37,pt=0,l=3,sg=0:0.0 Receiving initial value from controller 9353 TSF:MSG:SEND,100-100-0-0,s=1,c=1,t=37,pt=7,l=5,sg=0,ft=0,st=OK:25.70 9360 MCO:SLP:MS=3000,SMS=0,I1=255,M1=255,I2=255,M2=255 9365 TSF:TDI:TSL 9366 MCO:SLP:WUP=-1 9368 TSF:TRI:TSB 9379 TSF:MSG:SEND,100-100-0-0,s=1,c=1,t=37,pt=7,l=5,sg=0,ft=0,st=OK:26.90 9385 MCO:SLP:MS=3000,SMS=0,I1=255,M1=255,I2=255,M2=255 9391 TSF:TDI:TSL 9393 MCO:SLP:WUP=-1 9395 TSF:TRI:TSB
Again snapshot from core log:
2021-05-01 21:01:02 DEBUG (MainThread) [mysensors.transport] Receiving 100;1;1;0;43;Custom_Volt 2021-05-01 21:01:02 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 100 child 1 2021-05-01 21:01:02 DEBUG (MainThread) [mysensors.transport] Receiving 100;1;1;0;37;0.0 2021-05-01 21:01:02 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 100 child 1 2021-05-01 21:01:02 DEBUG (MainThread) [mysensors.transport] Receiving 100;1;2;0;37; 2021-05-01 21:01:02 DEBUG (MainThread) [mysensors.transport] Sending 100;1;1;0;37;0.0 2021-05-01 21:01:02 DEBUG (MainThread) [mysensors.transport] Receiving 100;1;1;0;37;25.70 2021-05-01 21:01:02 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 100 child 1 2021-05-01 21:01:05 DEBUG (MainThread) [mysensors.transport] Receiving 100;1;1;0;37;26.90 2021-05-01 21:01:05 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 100 child 1 2021-05-01 21:01:08 DEBUG (SyncWorker_0) [mysensors.persistence] Saving sensors to persistence file /config/mysensors_7d7c3a66687852fd3cb1b682191327ed.json
Remark - the two above log dumps are not necessarily in a sync But it shows that there is a working communication.
Content of the json file has been also updated:{ "0": { "sensor_id": 0, "children": {}, "type": 18, "sketch_name": null, "sketch_version": null, "battery_level": 0, "protocol_version": "2.3.2", "heartbeat": 0 }, "100": { "sensor_id": 100, "children": { "1": { "id": 1, "type": 6, "description": "", "values": { "43": "Custom_Volt", "37": "26.80" } } }, "type": 17, "sketch_name": "TestSensor", "sketch_version": "1.0", "battery_level": 0, "protocol_version": "2.3.2", "heartbeat": 0 }
So far so good!
And now the problems, I do not get any sensor in the HA I can read and reuse in lovelace or automation. The mysensor icon stays without any number of added sensors)
By the way I somehow managed to get one sensor integrated but without any entity so also useless. I deleted the integration and started again. Now I'm getting no progress.Do you have any idea where the problem is?
And the sketch for sensor:
#define MY_DEBUG #define MY_RADIO_NRF24 #include <MySensors.h> #define SN "TestSensor" #define SV "1.0" #define CHILD_ID 1 unsigned long SLEEP_TIME = 3000; // Sleep time between reads (in milliseconds) MyMessage msg(CHILD_ID, V_LEVEL); MyMessage msgPrefix(CHILD_ID, V_UNIT_PREFIX); // Custom unit message. bool initialValueSent = false; void setup() { Serial.println("Starting Sensor"); delay(1000); } void presentation() { Serial.println("Presenting Sensor"); sendSketchInfo(SN, SV); present(CHILD_ID, S_TEMP); } void loop() { if (!initialValueSent) { Serial.println("Sending initial value"); send(msgPrefix.set("Custom_Volt")); // Set custom unit. send(msg.set("0.0")); Serial.println("Requesting initial value from controller"); request(CHILD_ID, V_LEVEL); wait(2000, C_SET, V_LEVEL); } else { send(msg.set(25.0+random(0,30)/10.0,2)); sleep(SLEEP_TIME); } } void receive(const MyMessage &message) { if (message.type == V_LEVEL) { if (!initialValueSent) { Serial.println("Receiving initial value from controller"); initialValueSent = true; } } }
Any your idea is very much appreciated!
Best
Peter
- Created serial gateway with standard gateway sketch from arduino examples
-
This looks good to me...
So if you add an entity card now, and type sensor, it should show up this new TestSensor also. Doesn't it show up in the list?
-
Welcome @Petervf !
I think what throws Home Assistant off is the mismatch of S and V types in the node sketch:
MyMessage msg(CHILD_ID, V_LEVEL); present(CHILD_ID, S_TEMP);
Since you're faking and trying to build a temperature sensor, you should use
V_TEMP
instead ofV_LEVEL
.You also may need to manually remove the conflicting child object (or the whole node object, if that's easier for you) from the persistence file and restart Home Assistant. Power down the MySensors node beforehand, so it can't push new data into the file between you editing it and restarting HA.
Try to stick with S and V type combinations that match the listing on the serial protocol overview.
For Home Assistant specifically, I think you must match S and V types to any combination listed in this dictionary of sensor types to appear in the UI.
Edit: I remembered that there is a page dedicated to the MySensors sensors integration in the Home Assistant docs that also lists the supported types. So no need to crawl through the code base for this.
I also noticed that the sketch you posted above is very similar to the example on that page. I guess you just overlooked to adapt the V type accordingly.
-
@electrik
unfortunately it does not show up, there were some basic mistakes, stupid me@BearWithBeard said in Missing sensor in home assistant integration:
I think what throws Home Assistant off is the mismatch of S and V types in the node sketch:
MyMessage msg(CHILD_ID, V_LEVEL); present(CHILD_ID, S_TEMP);
Since you're faking and trying to build a temperature sensor, you should use
V_TEMP
instead ofV_LEVEL
.
I also noticed that the sketch you posted above is very similar to the example on that page. I guess you just overlooked to adapt the V type accordingly.Shame on me! That's it! I did miss this, embarrassing a bit. Thank you for pointing this out.
But there was one more very important config mistake I did!
In the integration configuration for serial gateway I gave mysensor version 2.3.2, which caused an error:2021-05-02 12:37:58 DEBUG (MainThread) [homeassistant.components.mysensors.helpers] Discovering platform sensor with devIds: [('64693e37f3f094b5131163d2f441c016', 100, 1, 0)] 2021-05-02 12:37:58 DEBUG (MainThread) [mysensors.transport] Receiving 100;1;2;0;0; 2021-05-02 12:37:58 DEBUG (MainThread) [mysensors.transport] Sending 100;1;1;0;0;0.00 2021-05-02 12:37:58 INFO (MainThread) [homeassistant.components.mysensors] Adding new devices: [<Entity TestSensor 100 1: None>] 2021-05-02 12:37:58 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: TestSensor 100 1: value_type 0, value = 0.00 2021-05-02 12:37:58 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event device_registry_updated[L]: action=create, device_id=5fabcf2db00c71f24b515861d461605f> 2021-05-02 12:37:58 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform mysensors Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 317, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 427, in _async_add_entity unit_of_measurement=entity.unit_of_measurement, File "/usr/src/homeassistant/homeassistant/components/mysensors/sensor.py", line 118, in unit_of_measurement float(self.gateway.protocol_version) >= 1.5 ValueError: could not convert string to float: '2.3.2' 2021-05-02 12:37:58 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 317, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 427, in _async_add_entity unit_of_measurement=entity.unit_of_measurement, File "/usr/src/homeassistant/homeassistant/components/mysensors/sensor.py", line 118, in unit_of_measurement float(self.gateway.protocol_version) >= 1.5 ValueError: could not convert string to float: '2.3.2' 2021-05-02 12:37:58 DEBUG (MainThread) [mysensors.transport] Receiving 100;1;1;0;0;25.70 2021-05-02 12:37:58 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 100 child 1
The sensor was discovered but without any entity - something I already got in the past.
The correct mysensors gateway version for 2.3.2 is "only" 2.3:
By correcting these two things, my first "sensor" works as desired!
Many thanks for your quick support!
Don't worry I will be coming backAnd for someone like me trying to test and looking for an example my corrected and working sketch:
/** * Documentation: https://www.mysensors.org * Support Forum: https://forum.mysensors.org * * https://www.mysensors.org/build/light */ #define MY_DEBUG #define MY_RADIO_NRF24 #include <MySensors.h> #define SN "TestSensor" #define SV "1.0" #define CHILD_ID 1 unsigned long SLEEP_TIME = 3000; // Sleep time between reads (in milliseconds) MyMessage msg(CHILD_ID, V_TEMP); bool initialValueSent = false; void setup() { Serial.println("Starting Sensor"); delay(1000); } void presentation() { Serial.println("Presenting Sensor"); sendSketchInfo(SN, SV); present(CHILD_ID, S_TEMP); } void loop() { if (!initialValueSent) { Serial.println("Sending initial value"); send(msg.set(0.0,2)); Serial.println("Requesting initial value from controller"); request(CHILD_ID, V_TEMP); wait(2000, C_SET, V_TEMP); } else { send(msg.set(25.0+random(0,30)/10.0,2)); sleep(SLEEP_TIME); } } void receive(const MyMessage &message) { if (message.type == V_TEMP) { if (!initialValueSent) { Serial.println("Receiving initial value from controller"); initialValueSent = true; } } }
By the way I changed a bit the example from home assistance page. I did not like the way the first value from sketch is being sent. In the original code, even if the controller hasn't responded the sensor sends the values. I'm waiting with providing the sensor readings as long as the controller answers.
Cheers
Peter
-
Hi all,
I installed home-assistant (core version 2021.5.1) and I don't find mysensors extension.
Any help?Thanks in advance
-
@cnerone When you're logged into your Home Assistant instance, click "Configuration" in the sidebar, then "Integration" on the top of that page. Then click the big blue "+ Add Integration" button in the lower right corner and type MySensors in the searchbar that pops up.
-
Writing "my" I can se MyQ only...
No mysensors extension, even scrolling the whole list.
I tried from Android app, mobile browser and desktop browser tooAny suggestion?