Dashticz - General Discussions

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Locked
robgeerts
Posts: 1273
Joined: Saturday 24 January 2015 22:12
Target OS: NAS (Synology & others)
Domoticz version: 3.7067
Location: NL
Contact:

Re: New Dashboard Design v2, custom positioning and multiple screens

Post by robgeerts »

Hold on, like I said, this is not so strange, few minutes, let me fix it ;)
User avatar
HansieNL
Posts: 957
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New Dashboard Design v2, custom positioning and multiple screens

Post by HansieNL »

Rainscript devices:
1. On/off switch
2. Text device
Image

Code: Select all

{
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 116,
         "Data" : "Off",
         "Description" : "",
         "Favorite" : 0,
         "HardwareID" : 2,
         "HardwareName" : "Dummy",
         "HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
         "HardwareTypeVal" : 15,
         "HaveDimmer" : true,
         "HaveGroupCmd" : true,
         "HaveTimeout" : false,
         "ID" : "0001416D",
         "Image" : "Regen",
         "IsSubDevice" : false,
         "LastUpdate" : "2017-04-13 01:50:06",
         "Level" : 0,
         "LevelInt" : 0,
         "MaxDimLevel" : 100,
         "Name" : "Regen verwacht",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "Status" : "Off",
         "StrParam1" : "",
         "StrParam2" : "",
         "SubType" : "Switch",
         "SwitchType" : "On/Off",
         "SwitchTypeVal" : 0,
         "Timers" : "false",
         "Type" : "Light/Switch",
         "TypeImg" : "lightbulb",
         "Unit" : 1,
         "Used" : 1,
         "UsedByCamera" : false,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "285"
      },
      {
               "AddjMulti" : 1.0,
               "AddjMulti2" : 1.0,
               "AddjValue" : 0.0,
               "AddjValue2" : 0.0,
               "BatteryLevel" : 255,
               "CustomImage" : 0,
               "Data" : "Geen regen verwacht binnen komende 30 minuten",
               "Description" : "",
               "Favorite" : 0,
               "HardwareID" : 2,
               "HardwareName" : "Dummy",
               "HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
               "HardwareTypeVal" : 15,
               "HaveTimeout" : false,
               "ID" : "00082286",
               "LastUpdate" : "2017-04-13 03:55:03",
               "Name" : "Regen mm/uur",
               "Notifications" : "false",
               "PlanID" : "0",
               "PlanIDs" : [ 0 ],
               "Protected" : false,
               "ShowNotifications" : false,
               "SignalLevel" : "-",
               "SubType" : "Text",
               "Timers" : "false",
               "Type" : "General",
               "TypeImg" : "text",
               "Unit" : 1,
               "Used" : 1,
               "XOffset" : "0",
               "YOffset" : "0",
               "idx" : "286"
      }
Last edited by HansieNL on Thursday 13 April 2017 10:51, edited 1 time in total.
Blah blah blah
robgeerts
Posts: 1273
Joined: Saturday 24 January 2015 22:12
Target OS: NAS (Synology & others)
Domoticz version: 3.7067
Location: NL
Contact:

Re: New Dashboard Design v2, custom positioning and multiple screens

Post by robgeerts »

EdKo66 wrote:
HansieNL wrote:@EdKo66 are you sure this is the right IDX for this switch? Looks like the picture is the on/off switch and the data output looks like the text device to me.
That is what's confusing me atm.

I created a text device, with IDX 113
Image.

When I return from the evil that is grocery-shopping, I will take another look at the scripts in that topic and see what I can do.
Try latest version!
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: New Dashboard Design v2, custom positioning and multiple screens

Post by Nautilus »

koowee wrote: Try to enable screens (one screen, it should show colums 1-3)

example

Code: Select all

//if you want to use multiple screens, use the code below:
var screens = {}
screens[1] = {}
screens[1]['background'] = 'bg1.jpg';
screens[1]['columns'] = [1,2,3]
//screens[2] = {}
//screens[2]['background'] = 'bg3.jpg';
//screens[2]['columns'] = [4,5,6]
The default config I started with had screens[1] enabled so yes I've tested that. It's only now when I saw the latest default config I also tried disabling the whole screens section :)
User avatar
HansieNL
Posts: 957
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New Dashboard Design v2, custom positioning and multiple screens

Post by HansieNL »

robgeerts wrote:
EdKo66 wrote:
HansieNL wrote:@EdKo66 are you sure this is the right IDX for this switch? Looks like the picture is the on/off switch and the data output looks like the text device to me.
That is what's confusing me atm.

I created a text device, with IDX 113
Image.

When I return from the evil that is grocery-shopping, I will take another look at the scripts in that topic and see what I can do.
Try latest version!
Hello Rob,
No text is shown just a switch. I've posted my rainscript info with a picture, so you can see how it looks like in Domotiz.
Blah blah blah
axelbaas
Posts: 28
Joined: Thursday 14 January 2016 20:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New Dashboard Design v2, custom positioning and multiple screens

Post by axelbaas »

robgeerts wrote:
EdKo66 wrote:
HansieNL wrote:@EdKo66 are you sure this is the right IDX for this switch? Looks like the picture is the on/off switch and the data output looks like the text device to me.
That is what's confusing me atm.

I created a text device, with IDX 113
Image.

When I return from the evil that is grocery-shopping, I will take another look at the scripts in that topic and see what I can do.
Try latest version!
It is working now! I had to change the name of this text box to : 'Rain Expected' . But now it is working.! Tnx!
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: New Dashboard Design v2, custom positioning and multiple screens

Post by Nautilus »

Nautilus wrote:
koowee wrote: Try to enable screens (one screen, it should show colums 1-3)

example

Code: Select all

//if you want to use multiple screens, use the code below:
var screens = {}
screens[1] = {}
screens[1]['background'] = 'bg1.jpg';
screens[1]['columns'] = [1,2,3]
//screens[2] = {}
//screens[2]['background'] = 'bg3.jpg';
//screens[2]['columns'] = [4,5,6]
The default config I started with had screens[1] enabled so yes I've tested that. It's only now when I saw the latest default config I also tried disabling the whole screens section :)
Ok, now I'm getting somewhere. I started with instructions here: https://gitlab.com/robgeerts/dashboard/ ... ositioning
and removed everything and then just added the three columns with idx's as suggested. And suddenly it works.

However, I cannot pinpoint what the issue was at first place. I can now add e.g. the screens and still working...:) I did a git pull as well, not sure if it can have some effect to all this.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by EdwinK »

Getting there

Image
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
HansieNL
Posts: 957
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by HansieNL »

EdKo66 wrote:Getting there

Image
You still need to install the script correct? If so and need help... just yell ;)
Image
Blah blah blah
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by EdwinK »

I've got this script. Guess that is the wrong one? I don't see anywhere to place the idx for the switch/text
Spoiler: show
----------------------------------------------------------------------------------------------------------------
-- IsItGonnaRain( int minutesinfuture)
-- returns: int avarage rainfall for the next minutesinfuture
--
-- Function to get rain prediction from Buienradar.nl (dutch)
--
-- http://gratisweerdata.buienradar.nl/#Buienradar You may use their free service for non-commercial purposes.
--
-- Written in LUA by Hans van der Heijden (h4nsie @ gmail.com)
-- Spring 2015
-- 14-11-2016 v0.4 changed lat/lon to max 2 decmals after comma
-- 28-03-2015 v0.3 bug: quotes around url added.
-- 27-03-2015 v0.2 return value is now average for next time
-- 26-03-2015 v0.1 Initial release
-- todo: some error checking on http and file handling (tmp file)
----------------------------------------------------------------------------------------------------------------
function IsItGonnaRain( minutesinfuture )
-- config ---------------------------------------------------------
lat='51.866' -- example lat/lon for Rhoon
lon='4.41' -- NOTE: lat and lon should have max 2 decimals after comma to function (requirement Buienrader)
debug=true
tempfilename = '../volume3/Rain.tmp' -- can be anywhere writeable
-- config ---------------------------------------------------------

-- url='http://gps.buienradar.nl/getrr.php?lat= ... lon='..lon
-- isn't working sice 2016/08/29: url is changed in:
url='http://gadgets.buienradar.nl/data/raint ... lon='..lon
if debug then print(url) end
read = os.execute('curl -s -o '..tempfilename..' "'..url..'"')
file = io.open(tempfilename, "r")
totalrain=0
rainlines=0
-- now analyse the received lines, format is like 000|15:30 per line.
while true do
line = file:read("*line")
if not line then break end
if debug then print('Line:'..line) end
linetime=string.sub(tostring(line), 5, 9)
if debug then print('Linetime: '..linetime) end

-- Linetime2 holds the full date calculated from the time on a line
linetime2 = os.time{year=os.date('%Y'), month=os.date('%m'), day=os.date('%d'), hour=string.sub(linetime,1,2), min=string.sub(linetime,4,5), sec=os.date('%S')}
difference = os.difftime (linetime2,os.time())

-- When a line entry has a time in the future AND is in the given range, then totalize the rainfall
if ((difference > 0) and (difference<=minutesinfuture*60)) then
if debug then print('Line in time range found') end
rain=tonumber(string.sub(tostring(line), 0, 3))
totalrain = totalrain+rain
rainlines=rainlines+1
if debug then print('Rain in timerange: '..rain) end
if debug then print('Total rain now: '..totalrain) end
end

end
file:close()

-- Returned value is average rain fall for next time
-- 0 is no rain, 255 is very heavy rain
-- When needed, mm/h is calculated by 10^((value -109)/32) (example: 77 = 0.1 mm/hour)
averagerain=totalrain/rainlines

return(averagerain)
end

commandArray = {}

time = os.date("*t")
if ((time.min % 15)==0) then

----- REGEN ------
minuten=15
regen = IsItGonnaRain(minuten)
print('Regen verwacht: '..regen..' mm binnen '..minuten..' minuten.')

if regen > 70 and otherdevices['Rain expected']=='Off' then
commandArray['SendNotification']='Regenscript#Regen verwacht'
commandArray['Rain expected']='On'
end
if regen == 0 and otherdevices['Rain expected']=='On' then
commandArray['SendNotification']='Regenscript#Geen regen meer verwacht'
commandArray['Rain expected']='Off'
end

end

return commandArray
So, if you can help me ;)
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
HansieNL
Posts: 957
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by HansieNL »

You got these two lines in your script? If not you got a different script.
-- Rain switch (ON when rain above threshold, else OFF)
local rainswitchname = "Regen verwacht" -- (str) name for switch to toggle
-- Virtual device (txt) displays textual result
local idxRegenmmUur = 286 -- IDX for virtual (text) sensor

You also got to change the following lines:
-- URL for data rewquest
local requesturl = "http://gadgets.buienradar.nl/data/raint ... lon='..lon"
Blah blah blah
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by EdwinK »

HansieNL wrote:You got these two lines in your script? If not you got a different script.
-- Rain switch (ON when rain above threshold, else OFF)
local rainswitchname = "Regen verwacht" -- (str) name for switch to toggle
-- Virtual device (txt) displays textual result
local idxRegenmmUur = 286 -- IDX for virtual (text) sensor

You also got to change the following lines:
-- URL for data rewquest
local requesturl = "http://gadgets.buienradar.nl/data/raint ... lon='..lon"

Looks like it's a different one. Looking up yours. Is that the one on the first post?
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
HansieNL
Posts: 957
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by HansieNL »

Nope. I took that one from page 5.
Blah blah blah
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by EdwinK »

HansieNL wrote:Nope. I took that one from page 5.

That was the one I started with, but installed again. Now hoping it will work.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
pkrabben
Posts: 55
Joined: Sunday 09 April 2017 15:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Almere
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by pkrabben »

EdKo66 wrote:
HansieNL wrote:Nope. I took that one from page 5.

That was the one I started with, but installed again. Now hoping it will work.
I'm also looking for the right script that I can use.
So if anybody have it working can you please share the script
User avatar
HansieNL
Posts: 957
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by HansieNL »

Code: Select all

-- =============================================================================================================
-- IsItGonnaRain( int minutesinfuture)
-- returns: int avarage rainfall for the next minutesinfuture
-- =============================================================================================================
-- Function to get rain prediction from Buienradar.nl (dutch)
-- Original script here: https://www.domoticz.com/wiki/Is_it_gonna_rain
--
-- Written in LUA by Hans van der Heijden (h4nsie @ gmail.com)
-- Spring 2015
-- 28-03-2015 v0.3 bug: quotes around url added.
-- 27-03-2015 v0.2 return value is now average for next time
-- 26-03-2015 v0.1 Initial release
-- todo: some error checking on http and file handling (tmp file)
----------------------------------------------------------------------------------------------------------------
-- Marco van Wijngaarden
-- 30-08-2016 v1.0 Adopted and updated the above scripts
-- 30-08-2016 v1.1 Updated the request URL, apparently buienrader is redirecting to different url
-- 30-08-2016 v1.2 Updated CURL to follow redirect and reverted (back to documented) request URL
--
----------------------------------------------------------------------------------------------------------------
-- Buienradar.nl --
---------------------
-- Gratis Weerdata --
--
-- Buienradar stelt gratis weerdata beschikbaar voor particulieren en bedrijven (website/intranet). 
-- Het gebruik van onderstaande weerdata is alleen toegestaan voor niet-commerciële doeleinden. 
-- Het gebruik voor mobiele toepassingen of commerciële doeleinden vereist toestemming van Buienradar, zie ook de Disclaimer.
-- Vraag hier toestemming aan voor het gebruik van de weerdata: http://www.buienradar.nl/overbuienradar/contact 
-- Vragen, suggesties of een leuk idee? Neem contact met ons op en bouw mee aan Buienradar!
-- 
------------------------------------------------------------
-- Buienradar widget - Neerslagdata op basis van coördinaten
------------------------------------------------------------
--
-- Op basis van de door u gewenste coördinaten (latitude en longitude) kunt u de neerslag tot twee uur vooruit ophalen in tekstvorm. 
-- De data wordt iedere 5 minuten geüpdatet. 
-- Op deze pagina kunt u de neerslag in tekst vinden: http://gps.buienradar.nl/getrr.php?lat=51&lon=3
-- De waarde 0 geeft geen neerslag aan (droog), de waarde 255 geeft zware neerslag aan. 
-- Gebruik de volgende formule voor het omrekenen naar de neerslagintensiteit in de eenheid millimeter per uur (mm/u):
-- Neerslagintensiteit = 10^((waarde-109)/32)
-- Ter controle: een waarde van 77 is gelijk aan een neerslagintensiteit van 0,1 mm/u.
--
-- =============================================================================================================
-- config ------------------------------------------------------------------------------------------------------
-- =============================================================================================================
--
-- Set your local position (latitude and longitude)
local latitude                  = '59.43'			    -- your home latitude, set as a user variable
local longitude                 = '12.31'			    -- your home longtitude, set as a user variable
-- timewindow for prediction
local minutesinfuture           = 30                                -- (int) minutes in future to calculate rain
-- threshold for switch (when do we actually call it rain and want to act accordingly)
local switchthreshold           = 70                                -- (int) value to toggle virtual switch
-- Rain switch (ON when rain above threshold, else OFF)
local rainswitchname            = "Regen verwacht"                  -- (str) name for switch to toggle
-- Virtual device (txt) displays textual result
local idxRegenmmUur             = 286                               -- IDX for virtual (text) sensor
-- Show results in log
local debug                     = 1                                 -- 1 = ON or 0 = OFF
-- NMA notifications (only during the day)
local notify                    = false                             -- (bool) set 'false' or 'true'
-- URL for data rewquest
local requesturl                = "http://gadgets.buienradar.nl/data/raintext?lat='..lat..'&lon='..lon" 
-- redirects to "http://gadgets.buienradar.nl/data/raintext"
-- Where do we store the data (tmp) file
local tempfilename              = "/home/pi/domoticz/scripts/tmp/rain.tmp"
-- default to activate script (set 'false' to run once every 5 minutes or 'true' to run every minute)
local active                    = false                             -- (bool) set 'false' or 'true'
--
-- =============================================================================================================
--
-- No edit required below this line
--
-- =============================================================================================================
--
-- execute (activate) every 5 minutes
local time = os.date("*t")
if ((time.min % 5)==0) then
    -- set to active
    active = true
end
--
-- =============================================================================================================
-- Functions ---------------------------------------------------------------------------------------------------
-- =============================================================================================================

-- function to split a string --
function splitString(str, delim, maxNb)
    -- Eliminate bad cases...
    if string.find(str, delim) == nil then
        return { str }
    end

    if maxNb == nil or maxNb < 1 then
        maxNb = 0    -- No limit
    end

    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos
    for part, pos in string.gmatch(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end
    -- Handle the last field
    if nb ~= maxNb then
        result[nb + 1] = string.sub(str, lastPos)
    end

    return result
end

-- function to request rain data 
function IsItGonnaRain(requesturl,latitude,longitude,tempfilename,minutesinfuture,debug)

    local averagerain = 0
    local totalrain = 0
    local rainlines = 0
    
    -- construct the request URL
    local url = requesturl..'?lat='..latitude..'&lon='..longitude
    
    -- print to log
    if (debug == 1) then print("| Request URL .............. : " .. url) end

    -- now get the data
    local trigger_action = 'curl -Lo '..tempfilename..' "'..url..'"' 
    -- CURL options:    -s for Silent (no error messages)
    --                  -o for Write output to file instead of stdout.
    --                  -L Follow redirects if the server reports that the requested page has moved (indicated with a Location: header and a 3XX response code)
    handle = os.execute(trigger_action)

    -- print request result to log
    if (debug == 1) then
        if handle then
            print("| CURL Data request ........ : Success")
        else
            print("! CURL Data request ........ : Failed")
        end
    end

    -- open file and process data
    file = io.open(tempfilename, "r")

        -- count datalines
        local linenbr = 0
        
        -- now analyse the received lines
        while true do
            line = file:read("*line")
            if not line then break end
            
            -- count received lines
            linenbr = linenbr+1
            
            -- line/data format is like 000|15:30 per line, we need to split the string
            raindata    = splitString(line,"|")
            rain        = tonumber(raindata[1])
            linetime    = raindata[2]

            -- Linetime2 holds the full date calculated from the time on each line
            linetime2   = os.time{year=os.date('%Y'), month=os.date('%m'), day=os.date('%d'), hour=string.sub(linetime,1,2), min=string.sub(linetime,4,5), sec=os.date('%S')}
            -- calculate the time difference between data/line and os time
            difference  = os.difftime (linetime2,os.time())

            -- When a line entry has a time in the future AND is within the given range, then add/totalize the rainfall
            if ((difference >= 0) and (difference <= minutesinfuture*60)) then
                
                -- print (relevant) data to log
                if (debug == 1) then print("| Rain data (line) ......... : " .. line) end
                
                -- calculate totals
                totalrain = totalrain+rain
                rainlines = rainlines+1
            end
        end
    -- close the file
    file:close()
    
    -- Returned value is average rain fall for next (int) minutes
    -- 0 is no rain, 255 is very heavy rain
    -- When needed, mm/h is calculated by 10^((value -109)/32) (example: 77 = 0.1 mm/hour)
    averagerain = totalrain/rainlines
    
    -- print summary to log
    if (debug == 1) then 
        print("| Rain data received # lines : " .. linenbr)
        print("| In timerange # lines ..... : " .. rainlines)
        print("| Total rain ............... : " .. totalrain)
        print("| Average rain calculated .. : " .. averagerain)
    end

    return(averagerain)

end

-- Functions to round a number to the given number of decimal places
-- returns result as string (text)
function round(num, idp)
  return string.format("%." .. (idp or 0) .. "f", num)
end
-- returns result as a number
function round2number(num, idp)
  return tonumber(string.format("%." .. (idp or 0) .. "f", num))
end

-- Note: If the number is rounded in order to be printed (as text) use function "round" (removed the tonumber function)
-- Converting to number then back to string would reintroduce rounding errors, so for numbers use "round2number" function

-- =============================================================================================================
-- Process -----------------------------------------------------------------------------------------------------
-- =============================================================================================================

commandArray = {}
-- start numbering at 1
indexArray=1

-- executes when active (every 5 minutes)
if (active) then

    -- when debugging set to 1, writing to log starts here
    if (debug == 1) then
        print("+--------------------------------------------------+")
        print("| =============== IS IT GONNA RAIN =============== |")
        print("+--------------------------------------------------+")
    end

    -- rain variables
    local regen = 0
    local regenmmUur = 0
    local rainstr = ""

    -- execute function (for given future minutes)
    regen = IsItGonnaRain(requesturl,latitude,longitude,tempfilename,minutesinfuture,debug)
    
    -- round result
    if (regen > 0) then
        regen = round2number(regen, 0)
    end

    -- convert rain to mm/uur
    if (regen > 0) then
        regenmmUur = 10^((regen-109)/32)
        regenmmUur = round(regenmmUur, 3)
    end

    -- textual result
    if (regen > 0) then
        rainstr = tostring("Regen verwacht: "..regen.." (".. regenmmUur.." mm/uur) binnen "..minutesinfuture.." minuten")
    else
        rainstr = tostring("Geen regen verwacht binnen komende "..minutesinfuture.." minuten")
    end

    -- write value to virtual (text) sensor
    if ((idxRegenmmUur) and (regenmmUur)) then
        commandArray[indexArray] = {['UpdateDevice'] = tostring(idxRegenmmUur)..'|0|'..rainstr}
        indexArray=indexArray+1
    end

    -- when debugging set to 1, write to log
    if (debug == 1) then 
        print("| Rain text ................ : " .. rainstr)
    end

    -- toggle switch ON
    if regen > switchthreshold and otherdevices[rainswitchname]=='Off' then
        
        -- send notification during the day
        if (timeofday['Daytime']) and (notify) then
            commandArray[indexArray] = {['SendNotification']=rainstr}
            indexArray=indexArray+1
        end
        
        -- change switch to ON
        commandArray[indexArray] = {[rainswitchname]='On'}
        indexArray=indexArray+1
    end

    -- toggle switch OFF
    if regen == 0 and otherdevices[rainswitchname] =='On' then
        
        -- send notification during the day
        if (timeofday['Daytime']) and (notify) then
            commandArray[indexArray] = {['SendNotification']=rainstr}
            indexArray=indexArray+1
        end
        
        -- change switch to OFF
        commandArray[indexArray] = {[rainswitchname]='Off'}
        indexArray=indexArray+1
    end

    -- logging end
    if (debug == 1) then
        print("+--------------------------------------------------+")
        print("| --------------------- END ---------------------- |")
        print("+--------------------------------------------------+")
    end

end

return commandArray
Blah blah blah
User avatar
HansieNL
Posts: 957
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New Dashboard Design v2, custom positioning and multiple screens

Post by HansieNL »

gielie wrote:@HansieNL

I use the same rainscript but i dont have the switch with text, i never got this to work, can you explain how you got this to work?
Or do i just have to create a text switch with "Rain expected"? Beacause when i do that i only get "Hello world"
https://www.domoticz.com/forum/viewtopi ... 40#p128669
Blah blah blah
NotsniwFrancisco
Posts: 2
Joined: Thursday 13 April 2017 12:59
Target OS: Windows
Domoticz version:
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by NotsniwFrancisco »

Hello there, I'm new here. I just want to say Wow! Looking really nice.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by EdwinK »

So far, the ouput in the log's looks okay i think

Code: Select all

17-04-13 13:33:00.026 LUA: +--------------------------------------------------+
2017-04-13 13:33:00.026 LUA: | =============== IS IT GONNA RAIN =============== |
2017-04-13 13:33:00.026 LUA: +--------------------------------------------------+
2017-04-13 13:33:00.026 LUA: | Request URL .............. : http://gadgets.buienradar.nl/data/raintext?lat='..lat..'&lon='..lon?lat=51.86&lon=4.41
2017-04-13 13:33:00.077 LUA: | CURL Data request ........ : Success
2017-04-13 13:33:00.077 LUA: | Rain data received # lines : 0
2017-04-13 13:33:00.077 LUA: | In timerange # lines ..... : 0
2017-04-13 13:33:00.078 LUA: | Total rain ............... : 0
2017-04-13 13:33:00.078 LUA: | Average rain calculated .. : nan
2017-04-13 13:33:00.078 LUA: | Rain text ................ : Geen regen verwacht binnen komende 30 minuten
2017-04-13 13:33:00.078 LUA: +--------------------------------------------------+
2017-04-13 13:33:00.078 LUA: | --------------------- END ---------------------- |
2017-04-13 13:33:00.078 LUA: +--------------------------------------------------+
2017-04-13 13:33:00.080 EventSystem: Script event triggered: Rain Expected
Image
Image

Still the tiles are left to work on
Image
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
pkrabben
Posts: 55
Joined: Sunday 09 April 2017 15:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Almere
Contact:

Re: Dashticz v2.0, custom positioning and multiple screens

Post by pkrabben »

EdKo66 wrote:So far, the ouput in the log's looks okay i think

Code: Select all

17-04-13 13:33:00.026 LUA: +--------------------------------------------------+
2017-04-13 13:33:00.026 LUA: | =============== IS IT GONNA RAIN =============== |
2017-04-13 13:33:00.026 LUA: +--------------------------------------------------+
2017-04-13 13:33:00.026 LUA: | Request URL .............. : http://gadgets.buienradar.nl/data/raintext?lat='..lat..'&lon='..lon?lat=51.86&lon=4.41
2017-04-13 13:33:00.077 LUA: | CURL Data request ........ : Success
2017-04-13 13:33:00.077 LUA: | Rain data received # lines : 0
2017-04-13 13:33:00.077 LUA: | In timerange # lines ..... : 0
2017-04-13 13:33:00.078 LUA: | Total rain ............... : 0
2017-04-13 13:33:00.078 LUA: | Average rain calculated .. : nan
2017-04-13 13:33:00.078 LUA: | Rain text ................ : Geen regen verwacht binnen komende 30 minuten
2017-04-13 13:33:00.078 LUA: +--------------------------------------------------+
2017-04-13 13:33:00.078 LUA: | --------------------- END ---------------------- |
2017-04-13 13:33:00.078 LUA: +--------------------------------------------------+
2017-04-13 13:33:00.080 EventSystem: Script event triggered: Rain Expected
Image
Image

Still the tiles are left to work on
Image
I created the script. In what folder do I need to store it. My virtual switch keeps telling "hello World"
Locked

Who is online

Users browsing this forum: No registered users and 1 guest