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


  • Hero Member

    This may be set in the gateway configuration either in PaperUI or via things-file:

    PaperUI:

    0_1515567322587_Bildschirmfoto vom 2018-01-10 07-54-36.png

    things-file:

    Wiki


  • Hero Member

    @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.


Log in to reply
 

Suggested Topics

  • 1
  • 5
  • 3
  • 2
  • 1
  • 2

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts