MySensors Multiple sensors on same child_id

Am trying to get read Energy Monitor through modbus and sending it through to HA through MySensors MQTT gateway.

When presenting S_POWER, HA expects 5 values (VA,VAR,W,KWH,PF) which i am sending.

the problem is, on auto discovery, the attribute of each of these entities will include the value of the other ones, it’s getting recorded and make db very bulky.

am i missing something here ?

You should create one child per measurement you want to report.

The child values are reported as state attributes for the user to take advantage of eg in automations. All child values are not always exposed as other entity attributes in all platforms.

Database design and consideration is part of the home assistant core. The mysensors component is using the core architecture/features and is following guidelines in this regard.

I’ve done that already, the issue is, when presentation is done, it expects the associated sensors data.

for example, when presenting Voltage (Child ID 1) as S_MULTIMETER, it expects V_CURRENT and V_IMPEDANCE

2017-12-27 11:36:44 DEBUG (Thread-23) [homeassistant.components.mysensors] Node update: node 0 child 1
2017-12-27 11:36:44 DEBUG (Thread-23) [homeassistant.components.mysensors] Invalid values: {38: ‘230.5’}: sensor platform: node 0 child 1: S_MULTIMETER requires value_type V_CURRENT @ data[39]
2017-12-27 11:36:44 DEBUG (Thread-23) [homeassistant.components.mysensors] Invalid values: {38: ‘230.5’}: sensor platform: node 0 child 1: S_MULTIMETER requires value_type V_IMPEDANCE @ data[14]

Same thing happens when Sending Current (Child 2) as S_MULTIMETER, expects V_VOLTAGE and V_IMPEDANCE

2017-12-27 11:36:44 DEBUG (Thread-21) [mysensors.gateway_mqtt] Receiving 0;2;1;0;39;1.7
2017-12-27 11:36:44 DEBUG (Thread-23) [homeassistant.components.mysensors] Node update: node 0 child 2
2017-12-27 11:36:44 DEBUG (Thread-23) [homeassistant.components.mysensors] Invalid values: {39: ‘1.7’}: sensor platform: node 0 child 2: S_MULTIMETER requires value_type V_VOLTAGE @ data[38]
2017-12-27 11:36:44 DEBUG (Thread-23) [homeassistant.components.mysensors] Invalid values: {39: ‘1.7’}: sensor platform: node 0 child 2: S_MULTIMETER requires value_type V_IMPEDANCE @ data[14]

That is just an example, similar thing happens when sending energy meter’s data (S_POWER) or Custom Data (S_CUSTOM).

Those are all debug level log messages. If you’re not experiencing any other issue, and your sensors are showing the values you’re expecting, you can ignore the debug messages.

This is mentioned here:

Note that the log will log all possible combinations of platforms for a child type that failed validation. It is normal to see some platforms fail validation if the child type supports multiple platforms and your sketch doesn’t send all corresponding value types.

Thanks, that makes sense.

Any idea how to pass HA friendly name for individual child ID? the auto generated one from HA are not actually friendly!

Customize the friendly name in customize under homeassistant in the configuration.yaml, or in the frontend editor for customize.

I struggled to understand this too.
Can the message validation be made smarter?
As far as I know, the sketch send function can only send the value of one variable at a time so it would be impossible for HA to validate all variables from a single message transmission.
Why not ignore the other possible variables and check only the one received?

I do agree that it makes sense to use another child ID for the other variables since the HA state supports just one value.

There are two different validation schemes used. One for the message and one for the child values. The latter validation checks all values of the child. The mentioned debug log messages comes from the child validation.

I agree that the debug log is confusing for new users, but I haven’t figured out a better way that is both informative enough but not confusing.

I do think that these debug log messages have value when debugging.

Here are links to my sketch that measures temperature, humidity, pressure, and battery voltage using a Moteino M0 with RFM69HW radio and BME280 breakout attached. Much lower power than an ESP8266 version I built earlier.


and my HA configuration:

Coming from the Home Assistant side I don’t understand why MySensors has so many sensor types that all do the same thing. Namely, reporting a floating point value.
In the above example, I use S_CUSTOM as the sensor type with the V_VAR1 variable type for all four of the sensor values sent to the controller (HA). It is easy to customize icon, friendly name and units as shown in the customize.yaml example.
Furthermore, I don’t understand how associating more than one variable type applies to a Home Assistant controller. Here is the communication sequence: One child ID sends one variable which becomes one state value. So I see no value in checking other possible MySensor variable types when one is received.
In my example I get DEBUG warnings for V_VAR2, V_VAR3, V_VAR3, V_VAR4, V_VAR5, and V_CUSTOM.
I suppose I could use S_HUM since it only has one variable type, V_HUM. That seems silly.
I don’t see any reason to check variable types that have not been received. I found it easy to debug just by looking at the HA states and the mysensors1.json file in the /config directory. The DEBUG messages just confused me.

Some platforms require or allow multiple value types per child, eg light and climate.

For fun, I tried to use multiple variable type per child. After presenting the child, I send one message for each of the variable types. One of the variable names is assigned to HA entity <Sketch Name>_<Node>1 and the remaining to <Sketch Name><Node>1_2, <Sketch Name><Node>_1_3 …etc
The HA state value is the variable type value and there are state attributes for each of the variable types.
(No complaints in the debug log about missing variable types even though V_VAR5 was never sent.)
The problem is the assignment of variable type to HA entity name seems random.
So like you said in your first reply:
“You should create one child per measurement you want to report.”
I am now using S_CUSTOM and V_CUSTOM for each child. I am getting debug messages about missing V_VAR1-5 which I will happily ignore.

I also tried the MySensors Light example from the HA component document page. Like you say it requires the use of two variable types for the S_DIMMER mysensor type assigned to a single child ID. Work fine in HA. V_STATUS goes to the HA entity state and V_PERCENTAGE goes to an attribute of the same HA entity.

PS.
I see that you are a contributor to the MySensors documentation.
I think the following #define needs to be added to each sketch example:

// Manually assign node number to prevent auto-increment,
// by the MySensors Gateway, everytime the node is reset.
// This will yield constant entity names in HA
#define MY_NODE_ID  1