Split at "temp/hum" sensor into separat hum and temp devices?
Moderators: leecollings, remb0
-
- Posts: 234
- Joined: Thursday 09 July 2015 12:03
- Target OS: Linux
- Domoticz version: 2.4538
- Location: Norway
- Contact:
Split at "temp/hum" sensor into separat hum and temp devices?
Ok, I Run Impreihome and it i not possible to change the icon for temp/Humidity devices, but it is possible on just temp sensors. (Weird, but that's how it is).
therfor I want to split ut my hum/temp sensors, or transfer the temp data to a dummy, same for Humidity.
Is this posible in a way?
therfor I want to split ut my hum/temp sensors, or transfer the temp data to a dummy, same for Humidity.
Is this posible in a way?
-
- Posts: 102
- Joined: Tuesday 04 March 2014 10:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Surrey, UK
- Contact:
Re: Split at "temp/hum" sensor into separat hum and temp devices?
I do this with my Oregon Scientific Thermometer & Humidity Sensor Remote Sensor & Aeotec Multi Sensor to split out the Thermometer & Humidity in to separate values.
The script below I use to split my Oregon & Aeotec but it may not work for you as it depends on the format of the raw data from the sensor, the Oregon & Aeotec both send there data in different formats.
The Oregon gets reported as temp;hum so they are split based on a match, where as the Aeotec reports as something different.
I know it took me some time with trial & error to get it working.
First you need to add the new virtual Temperature & Humidity sensors, make a note of there idx's
In the script you define the idx's of the virtual sensors to update.
eg local FGTidx = 166 --idx of virtual temp sensor "Front Garden Temperature"
"Front Garden" is the name of my Oregon sensor & "Lounge" is the name of the Aeotec sensor
Please note that this is a Time script & it runs every 10 mins.
The script below I use to split my Oregon & Aeotec but it may not work for you as it depends on the format of the raw data from the sensor, the Oregon & Aeotec both send there data in different formats.
The Oregon gets reported as temp;hum so they are split based on a match, where as the Aeotec reports as something different.
I know it took me some time with trial & error to get it working.
First you need to add the new virtual Temperature & Humidity sensors, make a note of there idx's
In the script you define the idx's of the virtual sensors to update.
eg local FGTidx = 166 --idx of virtual temp sensor "Front Garden Temperature"
"Front Garden" is the name of my Oregon sensor & "Lounge" is the name of the Aeotec sensor
Code: Select all
local Front Garden Temperature idx = 166 --idx of virtual temp sensor "Front Garden Temperature"
local Front Garden Humidity idx= 167 --idx of virtual humidity sensor "Front Garden Humidity"
local Lounge Temperature idx= 200 --idx of virtual temp sensor "Multi Sensor 1 Temperature"
local Lounge Humidity idx= 201 --idx of virtual humidity sensor "Multi Sensor 1 Humidity"
commandArray = {}
time = os.date("*t")
if((time.min % 10)==0)then
function round(num, idp) -- Credits go to Martin Rourke, I used his function.
local mult = 10^(idp or 1)
return math.floor(num * mult + 0.5) / mult
end
-- Split Oregon
sWeatherTemp, sWeatherHumidity = otherdevices_svalues['Front Garden']:match("([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
commandArray[1]={['UpdateDevice'] = Front Garden Temperature idx .. '|0|' .. tostring(sWeatherTemp)}
sWeatherHumidity = tonumber(sWeatherHumidity)
commandArray[2]={['UpdateDevice'] = Front Garden Humidity idx.. '|' .. (sWeatherHumidity) .. '|0'}
--Split Aeotec
MS1Temperature = round(otherdevices_temperature['Lounge'])
commandArray[3]={['UpdateDevice'] = Lounge Temperature idx.. '|0|' .. tostring(MS1Temperature)}
MS1humidity = otherdevices_humidity['Lounge']
commandArray[4]={['UpdateDevice'] = Lounge Humidity idx.. '|' .. (MS1humidity) .. '|0'}
end
return commandArray
3 x Pi, 1 Master, 2 Slaves, 1x Aeotec Z-Stick S2, 4xSP103 PIR, 5xPowerNode 1, 1xSmart Energy Switch Gen5, 4xFGSS101 Smoke Sensor, 2xFGD212, 9xFGS212 , 7xFGS221/2, 1xAD142 , 1xTKB TZ68E , 2xAeotec Multi Sensor, 3 x NodOn CRC-3-1-00.
-
- Posts: 234
- Joined: Thursday 09 July 2015 12:03
- Target OS: Linux
- Domoticz version: 2.4538
- Location: Norway
- Contact:
Re: Split at "temp/hum" sensor into separat hum and temp devices?
thanks for replay, have modified the script a little but noting i happening, just errors in console.
Running the scripts as "time" without det time-function inckluded (so every minute.
Devices:
"3 - Stue/Kjøkken" = idx 15 <-this one is the real device
"3 - Stue/Kjøkken - Luftfuktighet" = idx 234
"3 - Stue/Kjøkken - Temperatur" = idx 233
idx 15:
Current state: 23.6;30;2
sValues: 23.6;30;2
idx 234 (dummy):
Current state: 1
sValues: 1
idx 233 (dummy):
Current state: 0.0
sValues: 0.0
Any idea?
Code: Select all
2016-12-21 23:33:00.194 Error: EventSystem: in Temp/Fukt Splitter: [string "local temperature_dummy_idx = 233 ..."]:16: expected near 'end'
Code: Select all
local temperature_dummy_idx = 233
local humidity_dummy_idx = 234
commandArray = {}
-- Split
sWeatherTemp, sWeatherHumidity = otherdevices_svalues['3 - Stue/Kjøkken']:match("([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
commandArray[1]={['UpdateDevice'] = temperature_dummy_idx .. '|0|' .. tostring(sWeatherTemp)}
sWeatherHumidity = tonumber(sWeatherHumidity)
commandArray[2]={['UpdateDevice'] = humidity_dummy_idx.. '|' .. (sWeatherHumidity) .. '|0'}
end
return commandArray
"3 - Stue/Kjøkken" = idx 15 <-this one is the real device
"3 - Stue/Kjøkken - Luftfuktighet" = idx 234
"3 - Stue/Kjøkken - Temperatur" = idx 233
idx 15:
Current state: 23.6;30;2
sValues: 23.6;30;2
idx 234 (dummy):
Current state: 1
sValues: 1
idx 233 (dummy):
Current state: 0.0
sValues: 0.0
Any idea?
-
- Posts: 102
- Joined: Tuesday 04 March 2014 10:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Surrey, UK
- Contact:
Re: Split at "temp/hum" sensor into separat hum and temp devices?
It looks as if your sensor is returning 3 bits of data (23.6;30;2) so I think you may need to edit the following line
I know it took me a couple of days to sort it out with much trial & error.
Code: Select all
existing
sWeatherTemp, sWeatherHumidity = otherdevices_svalues['3 - Stue/Kjøkken']:match("([^;]+);([^;]+)")
New
sWeatherTemp, sWeatherHumidity, sWeatherOther = otherdevices_svalues['3 - Stue/Kjøkken']:match("([^;]+);([^;]+);([^;]+)")
3 x Pi, 1 Master, 2 Slaves, 1x Aeotec Z-Stick S2, 4xSP103 PIR, 5xPowerNode 1, 1xSmart Energy Switch Gen5, 4xFGSS101 Smoke Sensor, 2xFGD212, 9xFGS212 , 7xFGS221/2, 1xAD142 , 1xTKB TZ68E , 2xAeotec Multi Sensor, 3 x NodOn CRC-3-1-00.
Re: Split at "temp/hum" sensor into separat hum and temp devices?
I wanted to split my sensor values for a couple of reasons:
A thing to note (which I see was also part of the issue in the above posts) is that a humidity sensor uses the nValue for humidity percentage and the sValue for the "feeling" (or "status" as it's referenced in the API/JSON wiki), whereas the temperature sensor uses the sValue only.
To be certain I understood the UpdateDevice event syntax correctly, I had to verify in the domoticz source code, where I confirmed that index 0 was the idx, index 1 is the nValue and index 2 is the sValue:
Also, using the "string.format" you have to keep in mind to use the correct types. In my example I've only used "%d" (digit/integer) and "%f" (float/decimal number). When using floats you can specify how many decimals like this; "%.2f" for 2 decimals, "%.5f" for 5 decimals etc. "%s" is a string (anything enclosed in 'single' or "double" quotes essentially). I forgot this in the beginning so I kept getting my temperature as integers (3 rather than 3.5 f.ex).
And one last thing. Dumping all variables to the log is really helpful when trying to figure out what devices/events is available and what values they contain.
- Easier to replace a device in Domoticz (and retaining the log) when you don't have to worry about getting a TempHum to replace your previous TempHum. Now I can just split the values into dummy devices and then update the script with the new hardware devices.
- 2. Friendly sensor names for the Dashboard. I like to give my sensors longer and more descriptive names, but it doesn't look pretty on the Dashboard.
Code: Select all
commandArray = {}
-- Balcony
sensorTemperature, sensorHumidity, sensorHumidityStatus = otherdevices_svalues['Sensor1 (Clas Ohlson 36-4441)']:match("([^;]+);([^;]+);([^;]+)")
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%.2f", otherdevices_idx['Balcony Temperature'], sensorTemperature) })
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|%d|%d", otherdevices_idx['Balcony Humidity'], sensorHumidity, sensorHumidityStatus) })
-- Bathroom
sensorTemperature, sensorHumidity, sensorHumidityStatus = otherdevices_svalues['Sensor2 (Oregon THGR810)']:match("([^;]+);([^;]+);([^;]+)")
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%.2f", otherdevices_idx['Bathroom Temperature'], tonumber(sensorTemperature)) })
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|%d|%d", otherdevices_idx['Bathroom Humidity'], sensorHumidity, sensorHumidityStatus) })
-- Bedroom
sensorTemperature, sensorHumidity, sensorHumidityStatus = otherdevices_svalues['Sensor3 (Aeotec ZW100)']:match("([^;]+);([^;]+);([^;]+)")
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%.2f", otherdevices_idx['Bedroom Temperature'], sensorTemperature) })
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|%d|%d", otherdevices_idx['Bedroom Humidity'], sensorHumidity, sensorHumidityStatus) })
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%d", otherdevices_idx['Bedroom Lux'], otherdevices_utility['Sensor3 Lux (Aeotec ZW100)']) })
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%.2f", otherdevices_idx['Bedroom UV'], otherdevices_uv['Sensor3 UV (Aeotec ZW100)']) })
-- Closet
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%.2f", otherdevices_idx['Closet Temperature'], otherdevices_temperature['Sensor4 (Clas Ohlson 36-4744)']) })
-- Hallway
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%.2f", otherdevices_idx['Hallway Temperature'], otherdevices_temperature['Sensor5 (Clas Ohlson 36-4744)']) })
-- Living Room
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%.2f", otherdevices_idx['Living Room Temperature'], otherdevices_temperature['Sensor6 (Clas Ohlson 36-4744)']) })
-- Refrigerator/Kitchen
sensorTemperature, sensorHumidity, sensorHumidityStatus = otherdevices_svalues['Sensor7 (Clas Ohlson 36-4441']:match("([^;]+);([^;]+);([^;]+)")
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%.2f", otherdevices_idx['Refrigerator Temperature'], tonumber(sensorTemperature)) })
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|%d|%d", otherdevices_idx['Kitchen Humidity'], sensorHumidity, sensorHumidityStatus) })
return commandArray
To be certain I understood the UpdateDevice event syntax correctly, I had to verify in the domoticz source code, where I confirmed that index 0 was the idx, index 1 is the nValue and index 2 is the sValue:
Code: Select all
['UpdateDevice'] = idx|nValue|sValue
And one last thing. Dumping all variables to the log is really helpful when trying to figure out what devices/events is available and what values they contain.
-
- Posts: 10
- Joined: Monday 07 May 2018 14:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9272
- Location: Russia, Novosibirsk
- Contact:
Re: Split at "temp/hum" sensor into separat hum and temp devices?
My be someone has Dzvents example for this action? Split at temp/hum sensor into separate hum and temp devices?
-
- Posts: 10
- Joined: Monday 07 May 2018 14:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9272
- Location: Russia, Novosibirsk
- Contact:
Re: Split at "temp/hum" sensor into separat hum and temp devices?
It's me
DzVents script
DzVents script
Code: Select all
local REAL_TEMP_HUM_DEVICE = 'outdoor_temp_hum' -- Real temperature and humidity device name
local DUMMY_TEMP_DEVICE = 'outdoor_temp' -- Dummy temperature device name
local DUMMY_HUM_DEVICE = 'outdoor_hum' -- Dummy humidity device name
return {
on = {devices = {REAL_TEMP_HUM_DEVICE}},
logging = {
level = domoticz.LOG_ERROR,
marker = "temp_split"
},
execute = function(dz, trigger )
local virtualTemperatureSensor = dz.devices(DUMMY_TEMP_DEVICE)
local virtualHumiditySensor = dz.devices(DUMMY_HUM_DEVICE)
local masterTemperature = dz.utils.round(trigger.temperature,1)
local masterHumidity = dz.utils.round(trigger.humidity)
local masterHumidtyStatus = trigger.humidityStatusValue
local slaveTemperature = dz.utils.round(virtualTemperatureSensor.temperature,1)
local slaveHumidity = dz.utils.round(virtualHumiditySensor.humidity)
if slaveTemperature ~= masterTemperature then
virtualTemperatureSensor.updateTemperature(masterTemperature)
end
if slaveHumidity ~= masterHumidity then
virtualHumiditySensor.updateHumidity(masterHumidity,masterHumidtyStatus)
end
end
}
-
- Posts: 48
- Joined: Thursday 01 June 2017 8:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Latest
- Location: Netherlands
- Contact:
Re: Split at "temp/hum" sensor into separat hum and temp devices?
Hi guys,
I want to only use the temp and hum value of a multi sensor (tem, hum & baro) but cannot get that to work.
The sensor has THB1 - BTHR918, BTHGN129 as type description (Temp + Humidity + Baro).
Its a home weather station sensor and the baro value is very unreliable while temp and hum are okay.
Any tips on how to do that is much appreciated.
Greetings,
Harald
I want to only use the temp and hum value of a multi sensor (tem, hum & baro) but cannot get that to work.
The sensor has THB1 - BTHR918, BTHGN129 as type description (Temp + Humidity + Baro).
Its a home weather station sensor and the baro value is very unreliable while temp and hum are okay.
Any tips on how to do that is much appreciated.
Greetings,
Harald
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Split at "temp/hum" sensor into separat hum and temp devices?
What is unclear about the previous post ? @funnybu already shared a script to split the values and update a new virtual device with these values.Harald777 wrote: ↑Sunday 27 October 2019 18:38 I want to only use the temp and hum value of a multi sensor (tem, hum & baro) but cannot get that to work.
The sensor has THB1 - BTHR918, BTHGN129 as type description (Temp + Humidity + Baro).
Its a home weather station sensor and the baro value is very unreliable while temp and hum are okay.
Any tips on how to do that is much appreciated.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 48
- Joined: Thursday 01 June 2017 8:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Latest
- Location: Netherlands
- Contact:
Re: Split at "temp/hum" sensor into separat hum and temp devices?
Unfortunately not that clear to me. Will do some more investigation.waaren wrote:What is unclear about the previous post ? @funnybu already shared a script to split the values and update a new virtual device with these values.Harald777 wrote: ↑Sunday 27 October 2019 18:38 I want to only use the temp and hum value of a multi sensor (tem, hum & baro) but cannot get that to work.
The sensor has THB1 - BTHR918, BTHGN129 as type description (Temp + Humidity + Baro).
Its a home weather station sensor and the baro value is very unreliable while temp and hum are okay.
Any tips on how to do that is much appreciated.
Verstuurd vanaf mijn Nexus 5X met Tapatalk
-
- Posts: 587
- Joined: Wednesday 16 December 2015 19:13
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Netherlands
- Contact:
Re: Split at "temp/hum" sensor into separat hum and temp devices?
thanks funnybu
just got my Digoo R8S sensor and implemented your script.
seems to be working nicely. at first it did not update but now it does
just got my Digoo R8S sensor and implemented your script.
seems to be working nicely. at first it did not update but now it does
Who is online
Users browsing this forum: No registered users and 1 guest