Imperial Units
-
All,
I'm a newbie and have gotten mysensors working with openhab2 but I am having difficulty switching from metric to imperial. I have set the metric = false on the sensor node but believe it is still getting the config from the controller and can't figure out how to change the controller level.
I believe the problem is this line:
float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;Sorry if this has been answered somewhere else. I am having a difficult time finding this information.
Thanks,
Ryan
-
This may be set in the gateway configuration either in PaperUI or via things-file:
PaperUI:
things-file:
-
@ryan-dick said in Imperial Units:
I believe the problem is this line:
> float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
You are right, that line is asking your controller as to whether you are using metric or imperial and then giving the answer in the appropriate type.
I do not use openhab but it should have a place in settings to select the correct units to be used. If you already have imperial selected in openhab it may be that openhab does not support getControllerConfig() so is not returning the correct result.
If you only ever want the results to be in imperial you could just modify the line so it no longer asks for the config from the controller and just uses imperial. I have not tried it but something like this should work
float temperature = static_cast<float>(static_cast<int>((sensors.getTempFByIndex(i)) * 10.)) / 10.;
-
@timo Thank you this worked. The problem was I didn't even have the mysensors bindings installed and had got it working a different way (told you I'm a newbie lol). After getting it properly set up with mysensors binding it is working and much easier to manage.
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
Saving last known good state, but not in EEPROM
Development • 30 Jan 2024, 18:46 • OldSurferDude 15 Jan 2025, 08:51 -
Counting Incoming and Outgoing Messages from a Gateway
Development • 10 Dec 2024, 21:57 • Trand 14 Dec 2024, 20:23 -
Sending offset to node
Development • 31 Jan 2025, 00:59 • bsl88k 4 Feb 2025, 12:14 -
Home Assistant/MySensors quirks
Development • 17 Mar 2025, 02:35 • OldSurferDude 17 Mar 2025, 02:35 -
MQTT-Help me understand about the MQTT Gateway.
Development • 2 Mar 2025, 01:44 • dpcons 12 Mar 2025, 23:39