Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Imperial Units

Imperial Units

Scheduled Pinned Locked Moved Development
4 Posts 3 Posters 947 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Ryan DickR Offline
    Ryan DickR Offline
    Ryan Dick
    wrote on last edited by
    #1

    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

    Boots33B 1 Reply Last reply
    0
    • T Offline
      T Offline
      TimO
      Hero Member
      wrote on last edited by
      #2

      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

      Ryan DickR 1 Reply Last reply
      1
      • Ryan DickR Ryan Dick

        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

        Boots33B Offline
        Boots33B Offline
        Boots33
        Hero Member
        wrote on last edited by
        #3

        @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.;
        
        1 Reply Last reply
        0
        • T TimO

          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

          Ryan DickR Offline
          Ryan DickR Offline
          Ryan Dick
          wrote on last edited by
          #4

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

          1 Reply Last reply
          1
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          21

          Online

          11.7k

          Users

          11.2k

          Topics

          113.0k

          Posts


          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular