Page 1 of 1

Split Temperature Humidity

Posted: Monday 16 July 2018 12:47
by terrorsource
Hi,

I've already found a script that splits the TemperatureHumidty from my Aeotec MultiSensor6 into 2 dummy sensors:

Code: Select all

commandArray = {}
-- Bathroom
sensorTemperature, sensorHumidity, sensorHumidityStatus = otherdevices_svalues['MS_Badkamer_TempHum']:match("([^;]+);([^;]+);([^;]+)")
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|0|%.2f", otherdevices_idx['MS_Badkamer_Temp'], tonumber(sensorTemperature)) })
table.insert (commandArray, { ['UpdateDevice'] = string.format("%d|%d|%d", otherdevices_idx['MS_Badkamer_Hum'], sensorHumidity, sensorHumidityStatus) })

return commandArray
MS_Badkamer_TempHum = Aeotec MultiSensor 6
MS_Badkamer_Temp = Dummy Temperature
MS_Badkamer_Hum = Dummy Humidity

But this is constantly updating the dummy sensors, causing a lot of lines in the logs. I would like to have it update only when the value's of the seperate dummy sensors are different from the MultiSensor 6.

Can someone help me out with this?

Re: Split Temperature Humidity

Posted: Monday 16 July 2018 13:59
by emme
uh... are you sure
otherdevices_temperature['MS_Badkamer_Temp']
and
otherdevices_humidity['MS_Badkamer_Temp']

are not supported already for your device?

Re: Split Temperature Humidity

Posted: Monday 16 July 2018 14:32
by waaren
terrorsource wrote: Monday 16 July 2018 12:47
MS_Badkamer_TempHum = Aeotec MultiSensor 6
MS_Badkamer_Temp = Dummy Temperature
MS_Badkamer_Hum = Dummy Humidity

But this is constantly updating the dummy sensors, causing a lot of lines in the logs. I would like to have it update only when the value's of the seperate dummy sensors are different from the MultiSensor 6.
Something like ?

Code: Select all

-- splitBathroomSensor 

return {

    on =        {       devices   =   { "MS_Badkamer_TempHum"}},
              
    logging =   {       level   =   domoticz.LOG_ERROR,
                        marker  =   "splitBathroomSensor" },

    execute = function(dz, trigger )
        local virtualTemperatureSensor  = dz.devices('MS_Badkamer_Temp')
        local virtualHumiditySensor     = dz.devices('MS_Badkamer_Hum')
        
        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
}

Re: Split Temperature Humidity

Posted: Monday 16 July 2018 17:33
by terrorsource
emme wrote: Monday 16 July 2018 13:59 uh... are you sure
otherdevices_temperature['MS_Badkamer_Temp']
and
otherdevices_humidity['MS_Badkamer_Temp']

are not supported already for your device?
No, Aeotec MultiSensor 6 does not have seperate sensors. Everyone who's using this sensor has this "problem".

waaren wrote: Monday 16 July 2018 14:32
terrorsource wrote: Monday 16 July 2018 12:47
MS_Badkamer_TempHum = Aeotec MultiSensor 6
MS_Badkamer_Temp = Dummy Temperature
MS_Badkamer_Hum = Dummy Humidity

But this is constantly updating the dummy sensors, causing a lot of lines in the logs. I would like to have it update only when the value's of the seperate dummy sensors are different from the MultiSensor 6.
Something like ?

Code: Select all

-- splitBathroomSensor 

return {

    on =        {       devices   =   { "MS_Badkamer_TempHum"}},
              
    logging =   {       level   =   domoticz.LOG_ERROR,
                        marker  =   "splitBathroomSensor" },

    execute = function(dz, trigger )
        local virtualTemperatureSensor  = dz.devices('MS_Badkamer_Temp')
        local virtualHumiditySensor     = dz.devices('MS_Badkamer_Hum')
        
        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
}
Looks like it! Although i don't really get all of it but will take a look later this evening/tomorrow.

Re: Split Temperature Humidity

Posted: Sunday 28 October 2018 15:53
by terrorsource
I've now changed to a "Heiman Temperature Humidity Sensor HS1HT-Z+" from AliExpress but the script does not work.

Data of the sensor is "23.3 C, 54 %"

The script in the post above is only updating the Humidity and not the Temperature.

Re: Split Temperature Humidity

Posted: Sunday 28 October 2018 17:43
by waaren
terrorsource wrote: Sunday 28 October 2018 15:53 I've now changed to a "Heiman Temperature Humidity Sensor HS1HT-Z+" from AliExpress but the script does not work.

Data of the sensor is "23.3 C, 54 %"

The script in the post above is only updating the Humidity and not the Temperature.
can you execute the dumpscript below and send the dump output (preferable via PM).
Thanks

Code: Select all

-- dumper

return {

    on =        {       devices   =   { "name of your new temperature sensor"}},
              
    logging =   {       level   =   domoticz.LOG_DEBUG,
                        marker  =   "dumper" },

    execute = function(dz, item )
        item.dump()    
    end
}

Re: Split Temperature Humidity

Posted: Monday 29 October 2018 9:14
by terrorsource
waaren wrote: Sunday 28 October 2018 17:43
terrorsource wrote: Sunday 28 October 2018 15:53 I've now changed to a "Heiman Temperature Humidity Sensor HS1HT-Z+" from AliExpress but the script does not work.

Data of the sensor is "23.3 C, 54 %"

The script in the post above is only updating the Humidity and not the Temperature.
can you execute the dumpscript below and send the dump output (preferable via PM).
Thanks

Code: Select all

-- dumper

return {

    on =        {       devices   =   { "name of your new temperature sensor"}},
              
    logging =   {       level   =   domoticz.LOG_DEBUG,
                        marker  =   "dumper" },

    execute = function(dz, item )
        item.dump()    
    end
}
Script does not work.
Error: EventSystem: in dumper: [string "-- dumper..."]:7: attempt to index global 'domoticz' (a nil value)

Guess that is has something to do with "domoticz" "dz" use in the same script.
When i change them to the same, same error

Re: Split Temperature Humidity

Posted: Monday 29 October 2018 10:04
by waaren
terrorsource wrote: Monday 29 October 2018 9:14 Script does not work.
Error: EventSystem: in dumper: [string "-- dumper..."]:7: attempt to index global 'domoticz' (a nil value)
Guess that is has something to do with "domoticz" "dz" use in the same script.
When i change them to the same, same error
No script is OK as it was. You should only enter the name of your device.
Are you sure you saved it as a dzVents script ?