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


  • 0

Scene with time and temperature


Question

Posted

Hello, I'm new at this forum and sorry for my english.

I am trying to make a scene with blocks (since I haven't learned LUA yet) and an interactive push notification.

 

The wanted function is:

I want the interactive push to ask me only on weekdays (monday-friday) at a specific time and only if the temperature is below a certain value (for example 5degrees celsius)

If the temperature is below, I have the option to start another scene with a "yes or no" option in the notification, if the temperature is above it should not ask at all. 

 

As the block scene is right now I think it asks me everytime the temperature sensor reports a new value.

 

(Image on block scene attached)

This is how it looks when I convert from block to LUA:

 

--[[
%% autostart
%% properties
326 value
%% weather
%% events
%% globals
--]]

local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getValue(326, "value")) < 5 )
and
( ((currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "06:30") )
)
then
api.post('/mobile/push', {["mobileDevices"]={234}, ["message"]=[[INTERACTIVE PUSH QUESTION HERE]], ["title"]='NAME HERE OF THE SCENE THAT COULD BE STARTED', ["category"]='YES_NO', ["data"]={["sceneId"]=2}});
end

setTimeout(tempFunc, 60*1000)
end
if (sourceTrigger["type"] == "autostart") then
tempFunc()
else

local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getValue(326, "value")) < 5 )
and
( (currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) )
or
startSource["type"] == "other"
)
then
api.post('/mobile/push', {["mobileDevices"]={234}, ["message"]=[[INTERACTIVE PUSH QUESTION HERE]], ["title"]='NAME HERE OF THE SCENE THAT COULD BE STARTED', ["category"]='YES_NO', ["data"]={["sceneId"]=2}});
end

end

Please login or register to see this attachment.

5 answers to this question

Recommended Posts

  • 0
Posted

Hei, i can recommend using LUAScheduler for HC2 v1.1.5 original by robmac, contributions from jompa68 , A.Socha.

I was using several scenes to run different time based programs , all were run with autostart .

I use the above Lua Scheduler and have 8 or 9 programs that run simultaneously. 

 

Less CPU usage and easier to manage. 

Check site : 

Please login or register to see this link.

 

go about half way down and download : (look at skjermbilde below.)

 

Read and then read again, try and learn - great program..

 

Also recommend

Please login or register to see this link.

and

enclosed file from 10der..

 

I have not produced any of these programs, i am simply recommending.

 

 

Please login or register to see this attachment.

Please login or register to see this attachment.

  • 0
Posted

Hei igjen , just wondering if you found anything of interest? I made a few block scenes tonight that will work as you describe.

I made a block scene that turns on heating automatically when temp is under 5 C and sends message to phone.

The scene asks if you want to turn on then waits 20 seconds and asks again if you want to turn off. You can repeat this cycle as many times as you like and you can set time between pushes. 

I made 2 other scenes that turn on or off heating , depending on answer to push notifications.

I think that it is better to turn on the heating automatically in case you're away from phone. 

I am new many functions in lua and sometimes use block, change to lua , check forum, in order to learn.

I want a similar scene setup for heating outdoor and would like to be decide with one notification . I am looking av virtual devices to do this. Let me know if you figure out something.

Marcus

 

  • 0
  • Inquirer
  • Posted

    Hi Marcus, thanks for the reply and sorry for late respons. 

    I haven’t tried LUA scheduler yet, it seems a bit complicated but maybe I can try someday. 

    Can the block scene you made maybe work for me? The thing is I want to control what time it asks me, just once a day at a specific time. 

    • 0
    Posted

    Hei , have a look at this setup and adjust as needed.

     

    I have made 4 block scenes.

    1st Scene is main scene and will set condition - weather - timers - setting of variable and push notifications. picture 1

    2 nd Scene is to turn on heating picture 2

    3 rd Scene is to turn off heating picture 3

    4 th Scene is Setting of variable when temp is above 5 degrees. picture 4

     

     

    First make  variable for turning /activating scenes if the temp is over or under 5 degrees. This variable is either 0 (off) or (1) on. Using this variable will run or stop the scenes and can be used to run another scene/ push etc if you need.

     

    Go to: Panels - variables panel - variables (top panel) - and Add.

    Call it something that is relevant ( feks varme ) and save.

     

    Then go to Panels - Notifications panel - Add New - and make 2 notifications.

    1 st notification is - Title -(feks Varme På 5 Grader ) -and sms/ email/Push content. ( feks : Temp er under 5 Grader Slå på Varme).

     

    2 nd notification is - Title -(feks Varme Av 5 Grader ) -and sms/ email/Push content. ( feks : Temp er under 5 Grader Slå av Varme).

    (i used only push - but sending to mail and sms as well can be smart if the heating is critical?).

     

    Now you make Block Scenes:

     

    1. Make block scene (nr 2 ) Varme På and use newly crated variable (varme) as condition.

    (remember to set  :run scene manual:  and : Do not allow alarm to stop scene: before saving.

     

    2. Make block scene (nr 3 ) Varme Av and use newly crated variable (varme) as condition.

    (remember to set  :run scene manual:  and : Do not allow alarm to stop scene: before saving.

     

    3. Make block scene (nr 4 ) Temp Variable  and use weather conditions  and newly crated variable condition.

    (remember to set  :run scene Automatic:  and : Do not allow alarm to stop scene: before saving.

     

    4. Make block scene (nr 1.) 

    add the newly created variable (varme) < 5

    add timer - weekdays -exactly at time

    add notification; ( newly created notification) Varme På 5 Grader - yes/no - and scene (Varme På )- time when sent (red).  (this will appear in phone immediately and give you option to yes or no Varme på)

     

    add notification; ( newly created notification) Varme Av 5 Grader - yes/no - and scene (Varme Av )- time when sent (red).  (this will appear in phone immediately and give you option to yes or no Varme Av).

    (remember to set  :run scene Automatic:  and : Do not allow alarm to stop scene: before saving.

     

     

    I repeated this twice just to check, gives me the extra backup in case i am away from phone.

    With this set up i receive push notifications  at set intervals with the option to either turn on or turn off the heating.

     

    Ideally i would like the option to be able to turn on or off from a singel push notification ,

    yes - Varme På 

    no - Varme Av

    trying at the moment to fix this with lua and api. Let you know if i figure it out.

    I might also be smart to Copy all the scenes and store them , change to lua and learn more. Remember - changing from block to lua will give you a scene that is not so elegant. There are many well written scripts here on the forum that ; achieve more with less.

     

    Hope this helps a little.

    Marcus

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Pictures arrived in order - 4 -1-2-3

    Also i for for important 5 th scene - setting variable varme to 1. Make scene if temp is under 5 grader set variable temp to 1.  Missed this last night.

    • 0
    Posted

    Please login or register to see this image.

    /monthly_2019_03/1154316203_Skjermbilde2019-03-31kl_20_55_03.png.e4559f3e5f912a5e828f9f084c45ae31.png" alt="1154316203_Skjermbilde2019-03-31kl_20_55_03.png.e4559f3e5f912a5e828f9f084c45ae31.png" />

    Join the conversation

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

    Guest
    Answer this question...

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