Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. adi32k
    3. Best
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Best posts made by adi32k

    • RE: MQTT/OpenHab gw.request reply

      Thanks for the suggestion. I found another solution.

      I have the item like this:

      Switch Incalzire_Releu_GF_Living1 "Incalzire Releu Living 1" <heating> (Incalzire) {mqtt=">[mysensor:MyMQTT/3/1/V_HEATER_SW:command:ON:1],>[mysensor:MyMQTT/3/1/V_HEATER_SW:command:OFF:0],<[mysensor:MyMQTT/3/1/V_HEATER_SW:command:MAP(1on0off.map)]"}

      and in 1onoff.map i have:

      **1=ON
      0=OFF
      1.4.1=REQUEST
      **

      And then I have a rule:

      rule "SW1 Persist"
      when
      Item Incalzire_Releu_GF_Living1 received command
      then
      if (receivedCommand == "REQUEST")
      {
      sendCommand(Incalzire_Releu_GF_Living1 , Incalzire_Releu_GF_Living1.state);
      }
      end

      In the arduino code for the relay I have in the setu() this code.

      **void setup()
      {

      gw.begin(incomingMessage, AUTO, true);

      gw.sendSketchInfo("Relay Control", "1.0");

      for (int sensor=1 ; sensor<=NUMBER_OF_RELAYS;sensor++)
      {
      gw.present(sensor, S_HEATER);
      gw.request(sensor, V_HEATER_SW,0);
      }
      }**

      So whenever gw.request is called the idem receives an update with 1.4.1 that is resolved by the rule to the actual state of the switch in openhab.

      Like this, when arduino starts, the relays will be swiched ON as per the actual state of the switch.

      posted in OpenHAB
      adi32k
      adi32k