Fix mysensors metric/non-metric gateway (@MartinHjelmare - #58476) (mysensors docs)
Issue should be fixed in HomeAssistant 2021.11.0.
Fix mysensors metric/non-metric gateway (@MartinHjelmare - #58476) (mysensors docs)
Issue should be fixed in HomeAssistant 2021.11.0.
Opened an issue on HomeAssistant's github as this is sounding more and more like a HomeAssistant issue. If anyone experiencing same issue, perhaps you can bump that issue and add more info.
I have accomplished this in past within HomeAssistant using this component:
@Yveaux Agreed, but the nodes poll the gateway using the isMetric() function to determine what units to report. The gateway supposedly gets this info from the controller.
In my case, either my controller (HomeAssistant) isn't properly reporting that it is using imperial units or the gateways (two in use on 2.2 and 2.3.2 codebase) aren't correctly passing that information along to the nodes.
Still happening. No resolution found. Not sure if bug exists in MySensors code or in HomeAssistant's MySensors controller code - so not sure where to submit bug report.
Ethernet gateway running 2.2 and serial gateway running 2.3.2. isMetric isn't set properly (HomeAssistant set for imperial; nodes connected to new gateway all receive "true" referencing getConfig().isMetric so all temp measurements are reported using celsius values when HomeAssistant expecting fahrenheit.)
This might have started happening when I moved from YAML config to Integration in HomeAssistant.
HomeAssistant is latest version.
Controller (Nano) code is just the basic serial gateway code.
Is there a way on the gateway to override the isMetric setting received from the controller? I know that I can alter the code on each sensor to ignore, but I'd like to change this just on gateway so as not to have to recompile and upload new code to each sensor node.
Unless there has been a recent change I’m unaware of - I don’t think you can have RPi function as gateway when it is running Hass.IO (via HassOS). There is not a way to load and run the mysensors executable.
I’d suggest building a serial gateway with a nano (with NRF radio connected to nano). If you connect that via USB to your Pi, you should be able to use the homeassistant config for serial gateways to get everything working.
Seconding @Nightbodom -- Can't currently use RPi GPIO connection for NRF radio when running HassIO. You must use a serial, ethernet, or mqtt MySensors gateway.
And if you are going to need new hardware to set this up - you might want to look at ESP8266/32 as your gateway device as it has wifi/ethernet builtin.
Nice. Hadn't seen that doc before. Please let me know if there are any changes you suggest.
Example of a full Arduino sketch with 4 sensors/actuators using this library:
#define MY_RADIO_NRF24
#include <SPI.h>
#include <MySensors.h>
#include "MySensors_Node.h"
MySensors_Node node("Sample", "0.01");
void presentation() {
MySensors_Node_Sensor_Gpio_Out nsgo( 11, "Simple LED 1", 5, true );
node.add_sensor( &nsgo );
node.add_sensor( new MySensors_Node_Sensor_Gpio_In( 13, "Simple Motion", 2, true, INPUT_PULLUP, 500 ) );
node.add_sensor( new MySensors_Node_Sensor_Analog_In( 14, "Analog In", A0, true, 1024, 10000 ) );
node.add_sensor( new MySensors_Node_Sensor_Pwm( 15, "PWM LED", 6, true, true, 255 ) );
node.present();
}
void receive( const MyMessage &msg ) {
node.receive( msg );
}
void setup() {
node.setup();
}
void loop() {
node.loop();
}
@Dave-Myers said:
Oops - forgot to add: for MySensors 2.x only.
I've created a companion Arduino sketch / library to go along with the MySensors library. The companion library is designed with flexibility and inheritance to allow easy configuration of attached sensors and actuators. I.e. just tell the library you want to add a gpio output, an analog input, a PWM output, ... and the library handles all the necessary code. This makes the base Arduino sketch much simpler and allows for easier configuration and programming of modules with different and varying features.
I'm midway through development and have some more features to add, but I wanted to solicit some feedback to see if there were general ideas or concepts that I am missing. Note: I'm not a professional programmer and am learning some of this as I go!
The software is specifically designed for (and only tested with) the Home Assistant controller - though I hope other controller software is compatible.
Github here: https://github.com/brahmafear/MySensors_Node. Best starting point is the Arduino sketch listed in the examples folder.
Cheers.