Extracting a field from a multi-value sensor

Some devices in Domoticz contains mmm

ltiple values, separated by semicolon ';' :

  • kWh meters contain both power and energy, for example "950;11658" where 950 is the power
  • Temperature/Humidity sensors, for

ultiple values, separated by semicolon ';' :

  • kWh meters contain both power and energy, for example "950;11658" where 950 is the power
  • Temperature/Humidity sensors, for example "21.3;57" where temperature is 21.3°C and humidity 57%
  • Wind sensor, for example "135;ESE;3;9;12.4;12.4" where 3=wind speed*10 and 9 is gust*10  (windspeed=0.3m/s and gust=0.9m/s)

To extract a field from the device string, using a lua script, it's possible to use the following code:

 

devValue=otherdevices['WindSensor']
--devValue='109;ESE;8;15;123' The 3rd field, "8", contains the wind speed * 10 
i=0
for str in devValue:gmatch("[^;]+") do
    i=i+1
    if (i==3) then -- extract the third field
        windSpeed=tonumber(str)/10
        break
    end
end
print("windSpeed="..windSpeed)
if (windSpeed>5) then
    -- close the solar curtain, blinds, ...
    -- ToDo...
    -- if (otherdevices['devicePosition']=='Open') then
    --     commandArray['deviceMotor']='Close for 50 seconds'
    -- end
end 

ESPEasy sensors stopped working with Domoticz

Since 2023, Domoticz configuration denies by default access to the JSON API using plain http (not encrypted) protocol.
To enable http, select Setup -> Settings -> Security -> API Protection: Allow (enabled)

sensor device does not update: solved

Add icons to smartphone to enable and disable alarm system

It's very useful to have in the smartphone an icon to enable away alarm when leaving the house, and one to deactivate the alarm system before entering the house.

Adding icons on the smartphone to have HTTP URL shortcuts to some functions, such as alarm on and offDomoticz supports many HTTP commands to activate scenes, groups, switches, ... and smartphones have many applications that can be used to call such URLs.

  • Install on your smartphone the HTTP Shortcuts app
  • Create a new regular shortcut, specifying a name (in the example Alarm Away)
  • Specify the URL to call the Alarm Away group/scene (you have to edit that group/scene to get its idx, 13 in the example) writing the right parameters (IP, PORT, idx)
  • Enable base autentication, specifying the domoticz username and password
  • Choose an icon
  • Save, and add the icon to your smartphone home screen.
  •  Duplicate this icon, edit the new one, change name to Alarm Off, change icon, change URL replacing On with Off , save and add icon to the home screen.

Now you have two icons on the smartphone, one to activate alarm system and one to disable it.

How to change Domoticz graph sampling time

Domoticz, by default, show 3 graphs: a daily graph with 1 sample every 5 minutes, a monthly  graph and a yearly graph.

In some cases, 5 minutes is a very huge time if sensors data varies quickly: in these cases it's possible to reduce sampling interval for example to 1 minute (databases with sensors data will be much greater). In other cases, sensors data is very slow, so it's possible to set a longer sampling interval to save size and extend flash memory life.

To set a different sampling interval, it's possible to do as shown in the post https://www.domoticz.com/forum/viewtopic.php?f=47&t=10183&start=20#p129866

Edit the file DOMOTICZ_DIR/www/views/setup.html
Search for "shortlogtable" and add the following before the </table>-tag:

[code]<tr>
<td align="right" style="width:60px"><label><span data-i18n="Interval"></span>: </label></td>
<td><select id="comboshortloginterval" name="ShortLogInterval" style="width:60px" class="combobox ui-corner-all">
<option value="1">1</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
</select>&nbsp; Minutes
</tr>[/code]

Save it, delete your browser-cache and refresh your browser. I had problems with chrome keeping the old setup page even after deleting the cache, but using incognito mode worked to display the new page.

Finally, enter domoticz -> Setup -> Settings -> Log History and set the History value to 1 minute or longer sampling time.