Separating multi-value sensors on Dashboard

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
groovy
Posts: 17
Joined: Sunday 23 October 2016 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Separating multi-value sensors on Dashboard

Post by groovy »

I have some sensors, that measure multiple values. For example BMP180 (and soon BME280) sensors, that give temperature, pressure (and humidity). When I add such a sensor to the Dashboard, _all_ values for this sensor are added, but on the Dashboard I would like to have only the temperature for example.
When I remove the pressure sensor from Dashboard, the temperature sensor is removed too.
Is it possible to split those sensors, so I can choose, which values I have on the Dashboard and which not?
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: Separating multi-value sensors on Dashboard

Post by stlaha2007 »

Hmm kind of why i wanted the bme280 over the bmp180... Then as have to have just 1 as favorite Baro/Forecast and Temp/Hum...

Anyway yesterday i wrote a script which extracts the Forecast from WeatherUnderground and add it to the bme280 readings to fully update those 2 widgets.

And also wrote another script to update another device which extracts the roomtemperature from the temp-sensor and the setpoint from the thermostat device into a combined one.


[Edited now to include scripts...]
Hereby the Temp-Hum-Baro updated with python from bme280 itself and Forecast from WeatherUnderground:

Code: Select all

#!/usr/bin/python

## Import/Enable necessary functions for url, json and all from Adafruits downloaded Python Example
from Adafruit_BME280 import *
import urllib2, json
## Define Sensor Mode
sensor = BME280(mode=BME280_OSAMPLE_8)
## Fill Local Values (Normal and Raw Values) with specific functions
degrees = sensor.read_temperature()
pascals = sensor.read_pressure()
hectopascals = pascals / 100
humidity = sensor.read_humidity()
raw_degrees = sensor.read_raw_temp()
raw_pressure = sensor.read_raw_pressure()
raw_humidity = sensor.read_raw_humidity()

## Debug / Local Console Output
print 'Timestamp = {0:0.3f}'.format(sensor.t_fine)
print 'Temp      = {0:0.3f} deg C'.format(degrees)
print 'Humidity  = {0:0.2f} %'.format(humidity)
print 'Pressure  = {0:0.2f} hPa'.format(hectopascals)
#print degrees #print pascals #print humidity #print raw_degrees #print raw_pressure #print raw_humidity
print 'Compensated Values: ', degrees, pascals, humidity
##print 'Uncompensated Vals: ', raw_degrees, raw_pressure, raw_humidity

## Debug / Local Console Output
temp = format(degrees, '0.1f')
baro = format(pascals/100, '0.0f')
humi = format(humidity, '0.0f')
print 'Formatted Values: ', temp, humi, baro

## Old Humidity Status to get prediction in Forecast Field
# HUMIDITY_STATUS (EngineeringToolbox says <25% uncomfy Dry, >60% Uncomfy Wet, Comfy between 25-60%
# 0=Normal (45 - 60%), 1=Comfortable (30 - 45%), 2=Dry  (<30%), 3=Wet (>60%)
hum_stat = 0
if humi < 30: hum_stat = 2
if 30 <= humi < 45 : hum_stat = 1
if 45 < humi <= 60: hum_stat = 0
if humi > 60: hum_stat = 3
#print 'Humidity Status: ', hum_stat

#Domoticz URL and Sensor IDXes
idx_bme280 = 234
domoticz_url = "http://domoticz.shnetworks.lan:8080"
idx_wug = 35

#Get Baro_Status (Forecast Text feeded by value 0, 1, 2, 3 ,4 see also Domoticz Wiki JSON-API
forecast_get_url=str(domoticz_url)+'/json.htm?type=devices&rid='+str(idx_wug)
forecast_stat = json.load(urllib2.urlopen(forecast_get_url))
baro_stat = forecast_stat['result'][0]['Forecast']

#Construct Urls to push values into sensor
push_url = str(domoticz_url)+'/json.htm?type=command&param=udevice&idx='+str(idx_bme280)+'&nvalue=0&svalue='+str(temp)+';'+str(humi)+';'+str(hum_stat)+';'+str(baro)+';'+str(baro_stat)
push_request = urllib2.Request(push_url)
push_response = urllib2.urlopen(push_request)
answer = push_response.read()
#print forecast_get_url, push_url, push_request, push_response, answer
Hereby a bash-script which updates a Zone sensor reading values from Temp Living and Thermostat SetPoint:

Code: Select all

#!/bin/bash
#### Description of get_watermeter.sh
#### Purpose:		To read and write Current Living Temp and Thermostat Setpoint from/into Domoticz
#### Created:		2016-11-05
#### Modified:		2016-11-07 
#### Owner:		STLAHA2007
#### Functionalities:	Read current temp and setpoint from Domoticz  {curl/json/grep/awk/sed}
####			Write into combined Zone sensor to Domoticz  {curl/json/grep/awk/sed}
#### This script needs {Unix-style} execute rights (755 - rwx r-x r-x)
#### Declare temporary variables for read/calculate/write
declare    CurrentLiving_Temp
declare    CurrentLiving_SetPoint
declare -i CurrentLiving_Temp_IDX
declare -i CurrentLiving_SetPoint_IDX
declare    HeatZoneLiving_Value
declare -i HeatZoneLiving_IDX

declare DomoURL
DomoURL=$(echo "http://domoticz.shnetworks.lan:8080")

CurrentLiving_Temp_IDX=326
CurrentLiving_SetPoint_IDX=159
HeatZoneLiving_IDX=401

#### read and calculate current temp and setpoint
CurrentLiving_Temp=$(echo $(curl -s "$(echo $DomoURL)/json.htm?type=devices&rid=$(echo $CurrentLiving_Temp_IDX)" | grep "Data\"" | awk '{print $3}' | sed 's/\"//g' | sed 's/\,//g'| sed 's/\.000//g' )) 
CurrentLiving_SetPoint=$(echo $(curl -s "$(echo $DomoURL)/json.htm?type=devices&rid=$(echo $CurrentLiving_SetPoint_IDX)" | grep "Data\"" | awk '{print $3}' | sed 's/\"//g' | sed 's/\,//g'| sed 's/\.000//g' ))

HeatZoneLiving_Value=$(echo $(curl -s "$(echo $DomoURL)/json.htm?type=devices&rid=$(echo $HeatZoneLiving_IDX)" | grep "Data\"" ))

echo $CurrentLiving_Temp
echo $CurrentLiving_SetPoint
echo $HeatZoneLiving_Value

echo "HeatzoneLiving_Value needs to look like....:"
HeatZoneLiving_Value=$(echo $CurrentLiving_Temp";"$CurrentLiving_SetPoint";0;")

echo $HeatZoneLiving_Value
##echo "Electra: "$(echo $M_E_Curr)" kWh    Gas: "$(echo $M_G_Curr)" m3     Water: "$(echo $M_W_Curr)" m3"
curl -s "$(echo $DomoURL)/json.htm?type=command&param=udevice&idx=$(echo $HeatZoneLiving_IDX)&nvalue=0&svalue=$(echo $HeatZoneLiving_Value)"
You will see single to multisensors, or the other way around is possible....
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

Re: Separating multi-value sensors on Dashboard

Post by Flopp »

I also would like to be able to favorite only Pressure from my combined Temp/Hum/Pressure sensor(MySensors)
Rolo
Posts: 52
Joined: Sunday 27 December 2015 19:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: The Netherlands
Contact:

Re: Separating multi-value sensors on Dashboard

Post by Rolo »

+1 For splitting weather sensor values.

Verstuurd vanaf mijn ONEPLUS A3003 met Tapatalk
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: Separating multi-value sensors on Dashboard

Post by stlaha2007 »

I'm not a developer, but like to solve some needs.

A thing to remember is that Domoticz is build as a general working 'out-of-the-box'. So people can download/install/work with it.

Everyone has specific needs/wishes. Therefor forummembers write there own scripts or help others to write them.

I think when you look at the examples [eg. Above scripts] and implement them. You can enhance/modify it to your needs.

Above is build to retreive single data from multidata and pushing these as single or multidata.

Check wiki json-api and together you can enhance it.

If youre not able to read/write script, ask and supply environment details. I did wrote customized scripts for others here before ;-)
trixwood

Re: Separating multi-value sensors on Dashboard

Post by trixwood »

Just use virtual sensors to split them... not that difficult...
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

Re: Separating multi-value sensors on Dashboard

Post by Flopp »

stlaha2007 wrote:I'm not a developer, but like to solve some needs.

A thing to remember is that Domoticz is build as a general working 'out-of-the-box'. So people can download/install/work with it.

Everyone has specific needs/wishes. Therefor forummembers write there own scripts or help others to write them.

I think when you look at the examples [eg. Above scripts] and implement them. You can enhance/modify it to your needs.

Above is build to retreive single data from multidata and pushing these as single or multidata.

Check wiki json-api and together you can enhance it.

If youre not able to read/write script, ask and supply environment details. I did wrote customized scripts for others here before ;-)
You are so right.

I have now wrote a LUA script to retreive single-data from multi-data-device
My multi-data-device is a Temp/Hum/Pressure
Create a Virtual device, check what ID it gets, my virtual device is a Barometer with ID 318

Code: Select all

commandArray = {}

if devicechanged['DEVICE'] then  --if device with the data you want to retreive is changed

    local device = otherdevices_svalues["DEVICE"] --the device where the data you want to retreive, same as above
    print(device)  --show data string in LOG
    
    local temp, hum, humstat, pressure, forecast --create local variables
    
    _,_,temp, hum, humstat, pressure, forecast  = string.find(device, "(.+);(.+);(.+);(.+);(.+)") --fetch data string to varibales
   
    print(temp)  --show temp in LOG 
    print(hum)  --show humidity in LOG 
    print(var1)  --show humstat in LOG,
    print(pressure)  --show pressure in LOG 
    print(forecast)  --show forecast in LOG
    
    commandArray['UpdateDevice'] = '318|0|'..pressure..';'..forecast..''
   
end
return commandArray
Last edited by Flopp on Thursday 08 December 2016 13:37, edited 2 times in total.
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: Separating multi-value sensors on Dashboard

Post by stlaha2007 »

Nice :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests