5 Star Service
This guide shows how to extended the Fibaro Home Center 2's Sprinklers Panel's capabilities so that you can remotely adjust the watering period and automatically delay the next water cycle if the Fibaro weather reports show it's raining.
The Sprinklers panel allows you to manually add a 'Rain Delay' and increase/decrease the water cycle time from within the Sprinklers panel (see APNT-77 for details), however, you can't do this from the current smartphone app and you can't directly change them from a standard Home Center Scene.
By creating a Virtual device, together with a little bit of LUA code, you can have control of these functions and you can use a standard scene to adjust them based on the weather.
This guide shows you how to:
Note: This can only be used in Fibaro Home Center 2 (HC2) as it requires LUA coding - it cannot be used in Fibaro Home Center Lite (HCL)
A Virtual Device is just what it sounds like, a device that is not a physical device, but one created in Home Center to control other devices. This example shows a Virtual Device that can change the Sprinkler Panel's 'Rain Delay' (0, 24h, 48h) and 'Adjust Water' (0, 10%, 20%) values.
Figure 1: Virtual Device to control 'Rain Delay' and 'Adjust Water'
Figure 2: Creating a Virtual Device for the Sprinkler Panel
The Virtual Device needs two rows of three buttons - the first row controls the 'Rain Delay' and the second controls the 'Adjust Water' value.
Figure 3: Creating a Button in the Virtual Device
Each button will be controlled by a simple LUA script that takes the 'Rain Delay' or 'Adjust Water' value from the Sprinklers Panel, changes the value and then updates the panel.
-- Set authentication
HC2 = Net.FHttp("192.168.1.162",80)
fibaro:debug('Button LUA Triggered: ')
-- get data table from the Sprinklers Panel
response ,status, errorCode = HC2:GET("/api/panels/drenchers")
jsonTable = json.decode(response)
fibaro:debug('Rain Delay Value: ' ..jsonTable.rainDelay);
-- change data in LUA for 0 hours delay
jsonTable.rainDelay = 0
fibaro:debug('Rain Delay New Value: ' ..jsonTable.rainDelay);
-- send updated table to panel
json = json.encode(jsonTable);
fibaro:debug('Button LUA Finished: ')
The LUA code is split into sections by comment lines (which you can remove), it also includes several debug lines to help you test it within in the Virtual Device's debugger.
Debug lines: The blue lines (starting 'fibaro:debug) are debug lines which display values in the debug window - you can use these to confirm that the code is running correctly. You can delete these after the button is working.
Figure 4: LUA code in the Virtual Device's Button'
Now you need to configure the two remaining 'Rain Delay' buttons and the three 'Adjust Water' buttons, by repeating the above process.
The final Virtual device is shown in Figure 5, this has the Sprinkler icon rather than the standard Virtual Device icon - see APNT-72 - Changing Fibaro Home Center Icons. You can now make changes to the Sprinkler Panel's values without having to open it, and just as importantly, you can now change these values automatically from a Fibaro Scene.
Figure 5: Sprinkler Virtual Device with updated icon
We can now use the Sprinkler's Virtual Device as part of a scene to delay the sprinkler cycle by 24h if it has rained.
Home Center has a built-in weather report which it downloads regularly from Yahoo weather, we use this to determine if it has been raining.
Figure 6: Sprinkler Delay Scene based on Weather
This application note is based on testing by Vesternet as well as many useful forum posts from the users of the Fibaro Forum.