Values from two different sources

Begonnen von mflammia1, 16 November 2015, 21:52:50

Vorheriges Thema - Nächstes Thema

mflammia1


Hi,

Used some code liberated from here http://www.fhemwiki.de/wiki/ReadingsGroup

define HeatingValves readingsGroup <%sani_heating>,<Valve>,<SetTemp>,<Temp>,<Mode>,<Battery> TYPE=MAX:FILTER=type=HeatingThermostat:valveposition,desiredTemperature,temperature,mode,battery
attr HeatingValves mapping %ALIAS
attr HeatingValves nameStyle style="color:yellow;;font-weight:bold"
attr HeatingValves room Heat_Control,Heizung
attr HeatingValves valueFormat {'temperature' => "%.0f °C", 'desiredTemperature' => "%.0f °C", 'valveposition' =>"%.0f %%", 'maxValveSetting' =>"%.0f %%" }
attr HeatingValves valueIcon {'battery.ok' => 'batterie@lightgreen', 'battery.low' => 'batterie@red'}
attr HeatingValves valueStyle { if($READING eq "temperature" && $VALUE > 20){ 'style="color:green;;font-weight:bold"' }elsif( $READING eq "temperature" && $VALUE <= 20 ){ 'style="color:blue"' }elsif( $READING eq "temperature" && $VALUE > 23 ){ 'style="color:red"' }else{ 'style="color:gray"' } }


What I would like to do is use the temperature from my 'WallMountedThermostat' instead of that being taken from the 'HeatingThermostat', but not sure how to incorporate that into the code.

Any advice would be much appreciated.

Many thanks in advance

fruit

#1
The type HeatingThermostat has readings of
valveposition, desiredTemperature, temperature, mode, battery

that will be listed under columns/headings
alias, Valve, SetTemp, Temp, Mode, Battery

Your wall stat will have a type that you need to substitute for HeatingThermostat and readings likewise

Starting out it may be easier to set just the first two columns then add another column and reading in pairs until you have built what you need eg. your equivalent of
define HeatingValves readingsGroup <%sani_heating>,<Valve> TYPE=MAX:FILTER=type=HeatingThermostat:valveposition

Edit:
I think I misread your post, you want to readings of two devices :(

Take a look at Ausgabestil (hier rechtsbündig) in http://www.fhemwiki.de/wiki/ReadingsGroup and others where several devices are used eg.
define HeatingValves readingsGroup <%sani_heating>,<Valve>,<SetTemp>,<Temp>,<Mode>,<Battery>
TYPE=MAX:FILTER=type=HeatingThermostat:valveposition,desiredTemperature,temperature,mode,battery
TYPE=MAX:FILTER=type=WallThermostat:valveposition,desiredTemperature,temperature,mode,battery
Adjust to suit.
Note that in an fhem edit window you can split the define line like this to make it clearer - it will be saved with newline separators in fhem.cfg.
Remember to check for space delimiters if you convert back to a single line!
Feel free to follow up in German if you prefer

ph1959de

Hi,

there is a readingsGroup example that collects data from different devices here. It may not become obvious on the first glance, how to achieve that, because (un?)fortunately that sample in addition shows how to dynamically generate the dependent device names from the "primary" device (that's what the "valveOfDevice" subroutine does).

Basically you get data from the device of your choice by specifying readingname@device (or ?attributename@device, or +internalvaluename@device).

Peter
Aktives Mitglied des FHEM e.V. | Moderator im Forenbereich "Wiki"

mflammia1

Thanks for posting back.

It will no doubt be obvious once I have the exact code, but still struggling. Have tried lots of different combinations, none that seem to work of which here are some examples:

First I tried using the @ symbol different ways around but neither worked presumably as I've misinterpreted how to do it correctly:

TYPE=MAX:FILTER=type=HeatingThermostat:valveposition,desiredTemperature,temperature@WallMountedThermostat,mode,battery

or

TYPE=MAX:FILTER=type=HeatingThermostat:valveposition,desiredTemperature,WallMountedThermostat@temperature,mode,battery

Then I tried creating a single entry for the WallMountedThermostat for temperature, and this worked fine on its own:

define ThermoStat readingsGroup <Temp> TYPE=MAX:FILTER=type=WallMountedThermostat:temperature
attr ThermoStat valueFormat {'temperature' => "%.0f °C", 'desiredTemperature' => "%.0f °C", 'valveposition' =>"%.0f %%", 'maxValveSetting' =>"%.0f %%" }


But still struggling to amalgamate the two and replace the temperature reading of the HeatingThermostat with the temperature reading of the WallMountedTherostat?

define HeatingValves readingsGroup <%sani_heating>,<Valve>,<SetTemp>,<Temp>,<Mode>,<Battery> TYPE=MAX:FILTER=type=HeatingThermostat:valveposition,desiredTemperature,temperature,mode,battery
define ThermoStat readingsGroup <Temp> TYPE=MAX:FILTER=type=WallMountedThermostat:temperature
attr ThermoStat valueFormat {'temperature' => "%.0f °C", 'desiredTemperature' => "%.0f °C", 'valveposition' =>"%.0f %%", 'maxValveSetting' =>"%.0f %%" }
attr HeatingValves mapping %ALIAS
attr HeatingValves nameStyle style="color:yellow;;font-weight:bold"
attr HeatingValves room Heat_Control,Heizung
attr HeatingValves valueFormat {'temperature' => "%.0f °C", 'desiredTemperature' => "%.0f °C", 'valveposition' =>"%.0f %%", 'maxValveSetting' =>"%.0f %%" }
attr HeatingValves valueIcon {'battery.ok' => 'batterie@lightgreen', 'battery.low' => 'batterie@red'}
attr HeatingValves valueStyle { if($READING eq "temperature" && $VALUE > 20){ 'style="color:green;;font-weight:bold"' }elsif( $READING eq "temperature" && $VALUE <= 20 ){ 'style="color:blue"' }elsif( $READING eq "temperature" && $VALUE > 23 ){ 'style="color:red"' }else{ 'style="color:gray"' } }


Appreciate your further help in advance

ph1959de

Well,

if WallMountedThermostat is the name of the "other" device, then please do a
list WallMountedThermostat
(you should enter that in the command field) and check whether there is really a reading named "temperature".

Probably a "list" of your involved devices and of the readingsGroup together with a screenshot of the result you really get (from your readingsGroup) might help us in supporting you.

Also, did you check for any messages in the fhem-yyyy-mm.log that might be related to your attempts?

Peter
Aktives Mitglied des FHEM e.V. | Moderator im Forenbereich "Wiki"

fruit

ZitatIt will no doubt be obvious once I have the exact code
Always the way :)

Looking at your last pasted code, it looks as though you may be editing fhem.cfg directly.
That is very bad practice, you will break something sooner or later, possibly badly - many here will have learned that lesson the hard way

Edit from the web interface only, fhem will correctly format the config and provide warnings as you go.

Also
attr HeatingValves mapping %ALIASuses the alias of each device. Not sure what happens if not set but if you don't have an alias for each device set something simple, HStat1, HStat2, WStat1 etc.

It is often best to start with just a definition (for any device) and add attributes once all is working.
Feel free to follow up in German if you prefer

mflammia1

Thanks for all your support and patients so far, it is very much appreciated.

So here is where I am at the moment (see image below). I've got the two together but not how I want it.

Was hoping to replace the name and temperature of that from the WallMountedThermostat (readings at the bottom half) and perhaps add another column for the dates/time.

Have always added code straight into the FHEM config, so interesting to hear that isn't good practice - although I totally understand why :) Although not sure how I would have added the extra lines of code like:

TYPE=MAX:FILTER=type=WallMountedThermostat:temperature

into the main code as per below via the gui:

define HeatingValves readingsGroup <%sani_heating>,<Valve>,<SetTemp>,<Temp>,<Mode>,<Battery> TYPE=MAX:FILTER=type=HeatingThermostat:valveposition,desiredTemperature,temperature,mode,battery TYPE=MAX:FILTER=type=WallMountedThermostat:temperature
attr HeatingValves mapping %ALIAS
attr HeatingValves nameStyle style="color:yellow;;font-weight:bold"
attr HeatingValves room Heat_Control,Heizung
attr HeatingValves valueFormat {'temperature' => "%.0f °C", 'desiredTemperature' => "%.0f °C", 'valveposition' =>"%.0f %%", 'maxValveSetting' =>"%.0f %%" }
attr HeatingValves valueIcon {'battery.ok' => 'batterie@lightgreen', 'battery.low' => 'batterie@red'}
attr HeatingValves valueStyle { if($READING eq "temperature" && $VALUE > 20){ 'style="color:green;;font-weight:bold"' }elsif( $READING eq "temperature" && $VALUE <= 20 ){ 'style="color:blue"' }elsif( $READING eq "temperature" && $VALUE > 23 ){ 'style="color:red"' }else{ 'style="color:gray"' } }


Although what I think you are guiding me to is building it from scratch using the gui, which I need to learn more about.

Think I'm nearly there now anyway :)

ph1959de

Zitat von: mflammia1 am 20 November 2015, 00:28:04
Although not sure how I would have added the extra lines of code like: ...
A mouse click on "DEF" in the "Internals" section will show you (Wiki page Konfiguration might give you additional ideas, what is possible via the GUI).

Now, the remaining part may become difficult to describe.

I assume, you want (only) the temperature values of the "Thermostat" devices to be displayed in the corresponding "TVR" line? Then you need to go back to the readingsGroup sample I pointed to earlier, the one, which describes how to combine data from different devices (here). And you should ensure that you can derive the Thermostat-devices's name from the TVR device name. Based on that you should check and understand usage and definition of sub valveOfDevice and apply this to your situation.

Basically, I think the referenced sample is doing exactly what you want - only difference might be, that it is using the "Thermostat" device as the "primary" device.

Peter
Aktives Mitglied des FHEM e.V. | Moderator im Forenbereich "Wiki"