Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team



jgab

Recommended Posts

  • Topic Author
  • 1 minute ago, jompa68 said:

    Have not tried anything yet, you have some input to share? 

     

    I never used a thermostat.

    If you can do

    fibaro:call(deviceID,'turnOn')

    fibaro:call(deviceID,'turnOff')

    fibaro:getValue(deviceID,'value')

    it will work with ER. I guess there is some way to set a setpoint too?

    Link to comment
    Share on other sites

    2 minutes ago, jgab said:

    it will work with ER. I guess there is some way to set a setpoint too?

    Yes, possible to use setpoint, thinking to setup heat panel. Must read how that works first. Anyone of you using it at you home?

    Link to comment
    Share on other sites

  • Topic Author
  • 12 minutes ago, jompa68 said:

    Yes, possible to use setpoint, thinking to setup heat panel. Must read how that works first. Anyone of you using it at you home?

     

    There seems to be 2 operations one wants to do with thermostats

    Please login or register to see this code.

    setTime was already supported in ER and I pushed a new version (B63) that supports targetLevel

    Please login or register to see this code.

    If you set time or targetLevel does it generate a sourceTrigger back to the scene?

    Link to comment
    Share on other sites

  • Topic Author
  • 36 minutes ago, jompa68 said:

    Yes, possible to use setpoint, thinking to setup heat panel. Must read how that works first. Anyone of you using it at you home?

     

    Seems to be more actions possible. Can you post the device structure, especially with the actions field.

    E.g.what you get from  http://<HC2 IP>/api/devices/<controller deviceID>

    Link to comment
    Share on other sites

  • Topic Author
  • Ok, now there is support for (in B64)

    Please login or register to see this code.

    I don't know what the commands do :-) 

    :schedule takes 3 arguments so you need to make it a table of 3 arguments as '=', assignment only takes one value in ER.

     

    Link to comment
    Share on other sites

    Hallo @jgab , I am trying to move a scene which I use to show some measurements in Grafana via influxdb. Now I found node-red-influxdb-contrib and it works great when I send measurments fom OpenWeathermap in ER to this node. But how do I implement the following (which obviously doesn't work)?

    --[[
    %% properties
    309 value
    317 value
    %% events
    %% globals
    %% autostart 
    --]] 

    -- Don't forget to declare triggers from devices in the header!!!
    if dofile and not _EMULATED then _EMBEDDED={name="EventRunner", id=27} dofile("HC2.lua") end

    _version,_fix = "2.0","B59"  -- June 24, 2019  

    --[[
    -- EventRunner. Event based scheduler/device trigger handler
    -- Copyright 2019 Jan Gabrielsson. All Rights Reserved.
    -- Email: [email protected]
    --]]

    _sceneName   = "testing"      -- Set to scene/script name
    _homeTable   = "HomeTable" -- Name of your HomeTable variable (fibaro global)
    _HueHubs     = {}          -- Hue bridges, Ex. {{name='Hue',user=_HueUserName,ip=_HueIP}}
    _myNodeRed   = "http://192.168.1.158:1880/eventrunner" -- Ex. used for Event.postRemote(_myNodeRed,{type='test'})
    --if dofile then dofile("credentials.lua") end -- To not accidently commit credentials to Github, or post at forum :-)
    -- E.g. Hue user names, icloud passwords etc. HC2 credentials is set from HC2.lua, but can use same file.
    -- debug flags for various subsystems...
    _debugFlags = { 
      post=false,invoke=false,triggers=false,dailys=false,rule=false,ruleTrue=false,hue=false,msgTime=false,
      fcall=false, fglobal=false, fget=false, fother=false
    }
    _EVENTSERVER=true       -- Starts port on 6872 listening for incoming events (Node-red, HC2 etc)
    ---------------- Here you place rules and user code, called once at startup --------------------
    function main()
      local HT = type(_homeTable)=='number' and api.get("/scenes/".._homeTable).lua or fibaro:getGlobalValue(_homeTable) 
      HT = json.decode(HT)
      Util.defvars(HT)            -- Make HomeTable defs available in EventScript
      Util.reverseMapDef(HT)      -- Make HomeTable names available for logger
      local rule,define = Rule.eval, Util.defvar
       if _EMULATED then
        --_System.speed(true)               -- run emulator faster than real-time
        --_System.setRemote("devices",{5})  -- make device 5 remote (call HC2 with api)
        --_System.installProxy()            -- Install HC2 proxy sending sourcetriggers back to emulator
      end
      ---------------START TEST------------------------
     deviceList =
    {
     temperature = { Altandorrtemp = 85, AltanTemp = 14, 
        ForradsdorrTemp = 231, Balkondorr = 371, Friggebod = 387 },
     energy = { TV = 290},
     motion = { PirAltan = 13, PirTrappa = 439},
     door = { BalkongSov = 370,  AltanVrum = 84, Entre = 92, Tvatt = 34, 
        Forrad = 230, Friggebod = 386, TVmarkis = 252, Sovmarkis = 262},
     light = { Arbetsrum = 309, LillaSovr = 317 },
    }
    local sourceTrigger = fibaro:getSourceTrigger()

    if (sourceTrigger['type'] == 'property') then
       processOne(sourceTrigger['deviceID'])
    end

     

    function processOne(findDeviceID)
      for deviceClass, devices in pairs(deviceList) do
        for deviceName, deviceID in pairs(devices) do
          if (findDeviceID == deviceID) then
           rule("remote(_myNodeRed,#devices{class=deviceClass, name=deviceName, id=deviceID, data=deviceID:value}")
          end
        end
      end
    end

     

    function processAll()
      for deviceClass, devices in pairs(deviceList) do
        for deviceName, deviceID in pairs(devices) do

          rule("remote(_myNodeRed,#devices{class=deviceClass, name=deviceName, id=deviceID, data=deviceID:value}")
        end
      end
    end


    rule("@@00:02 => processAll()")

    Link to comment
    Share on other sites

  • Topic Author
  • 30 minutes ago, FrankT said:

    Hallo @jgab , I am trying to move a scene which I use to show some measurements in Grafana via influxdb. Now I found node-red-influxdb-contrib and it works great when I send measurments fom OpenWeathermap in ER to this node. But how do I implement the following (which obviously doesn't work)?

     

    This should work.

    You need to use the Lua function Event.postRemote instead of the rule(...).

    I do a reverse map of your deviceList so that it is quicker to lookup a device and get name and class - but you can do it your way too

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    1 hour ago, jgab said:

    his should work.

    You need to use the Lua function Event.postRemote instead of the rule(...).

    I do a reverse map of your deviceList so that it is quicker to lookup a device and get name and class - but you can do it your way too

     

    Working ok, great, thank you Jan.

    Link to comment
    Share on other sites

    Hallo Jan,

    If I arm gona arm the house I will check first if all doors and windows are closed if not >>>> telegram

    To arm I use:

            Rule.eval("serre.deur:breached & serre.deur:armed=='1' => post(#AlarmState); postRemote(1627,#AlarmState);  $Telegram='Alarm, serre.deur breached'")
            Rule.eval("woonkamer.raam:breached & woonkamer.raam:armed=='1' => post(#AlarmState); postRemote(1627,#AlarmState);  $Telegram='Alarm, woonkamer raam breached'")
            Rule.eval("keuken.deur:breached & keuken.deur:armed=='1' => post(#AlarmState); postRemote(1627,#AlarmState);  $Telegram='Alarm, keuken deur breached'")

    Suppose a door is open when I switch on "arm" does that result in an alarm?

    Its telling me every second I am in alarm!

    Please advice,

    Please login or register to see this image.

    /monthly_2019_07/image.png.3d867a62f35d2b6fb9111fc5ad9128d8.png" />

    Link to comment
    Share on other sites

  • Topic Author
  • To get the triggers when it is armed or breached you need declare 

    Please login or register to see this code.

    if serre.deur has deviceID 22. And for all the windows/doors.

    The reason you get a notification that you are in alarm every second must be some other rule. Can't see that from your log.

    Link to comment
    Share on other sites

    Hello Jan,

    Yep according your device I did those in header.

    Okay let me struggle a bit to see if I can find something.

    Link to comment
    Share on other sites

    @jgab today i control my SONOFF's devices with a VD but that fails to often so i would like to use ER instead. Did read some earlier post about httpGet, so is my understanding that line below should work?

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 8 hours ago, jompa68 said:

    @jgab today i control my SONOFF's devices with a VD but that fails to often so i would like to use ER instead. Did read some earlier post about httpGet, so is my understanding that line below should work?

    Please login or register to see this code.

     

     

    It's not a built-in function .- I provided it in an example for Sjakie

    Please login or register to see this code.

    very simple and no error checks besides the log.

    I have used the below example myself to retrieve the value from a get

    Please login or register to see this code.

    Ex. 

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    cannot get this simple rules to work, what am i doing wrong? 

    Please login or register to see this code.

     

    Edited by jompa68
    Link to comment
    Share on other sites

  • Topic Author
  • 8 minutes ago, jompa68 said:

    cannot get this simple rules to work, what am i doing wrong? 

    Please login or register to see this code.

     

    Are all the rules in the same scene? 'publish' will only send to other scenes (that subscribe). Within scenes use 'post'

     

    Edited by jgab
    Link to comment
    Share on other sites

    Just now, jgab said:

    Are all the rules in the same scene? 'publish' will only send to other scenes. Within scenes use 'post'

     

    No, 1 publish scene

    Please login or register to see this code.

    and this is in another scene

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 16 minutes ago, jompa68 said:

    No, 1 publish scene

    Please login or register to see this code.

    and this is in another scene

    Please login or register to see this code.

     

     

    I'm trying the same rule on my HC2 and it works ok. Have you declared pirSensor.wc in the %% properties header so it triggers?

    Add a log and see if it triggers

    Please login or register to see this code.

    Do you see that the event arrives in the subscribing scene(s) ? ("Incoming event...")

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...