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

Koubachi data in HC2


Question

Posted

I have a Koubachi and retrieving the data trough a php script, as mentioned on

Please login or register to see this link.

(Thanks guys!!!)

However, when the temp light and moist values are set in the Global Variable panel the symbols (°C, lx and %) are set as well. This causes trouble when using it in a scene as the variables are not seen as numbers and that is necessary as I want to use the moist value as a trigger.

I think this can be solved in 2 ways, but either way I don't know how. Who can help?

1) Try to set the values without the symbols. In this case I have to extract the pure values out of the json file through the php script. I have the following LUA code in my virtual device. How to adjust?

-- NAME: koubachi-fibaro

-- Author: Zebk

-- Date: 14/07/2013

-- Comment: Collecter les donnees d'un capteur Koubachi

HC2 = Net.FHttp("")

response = HC2:GET("/koubachi/Koubachi.php")

result = json.decode(response)

local light = result.device.recent_light_reading_value

local temp = result.device.recent_temperature_reading_value

local moisture = result.device.recent_soilmoisture_reading_value

i = 1

while i <= 360 do

fibaro:setGlobal("Koubachi_light",light)

fibaro:setGlobal("Koubachi_temp", result.device.recent_temperature_reading_value)

fibaro:setGlobal("Koubachi_moist", result.device.recent_soilmoisture_reading_value)

-- assign local variable to virtual device label

fibaro:call(177,"setProperty","ui.Label1.value",moisture)

fibaro:call(177,"setProperty","ui.Label2.value",temp)

fibaro:call(177,"setProperty","ui.Label3.value",light)

fibaro:log("Light: "..light.." - Temp: "..temp.." - Hum:"..moisture.."")

fibaro:sleep(1000);

i = i + 1

end

2) Adjusting the LUA code of the scene so that it can read the symbols for triggering below a certain value. First I used the scripting block without success. I have translated it to LUA code

(see below the first part of the code). If I have to do something here I think it should be where the trigger value is mentiod 'tonumber ( "75" ) )'. But how to adjust?

--[[

%% properties

%% globals

Koubachi_moist

--]]

local sourceTrigger = fibaro:getSourceTrigger();

if (sourceTrigger["type"] == "autostart") then

while true do

local currentDate = os.date("*t");

local startSource = fibaro:getSourceTrigger();

if (

( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "14:43") )

and

( tonumber(fibaro:getGlobalValue("Koubachi_moist")) < tonumber( "75" ) )

)

then[/color]

Who can help me solving this?

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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