sebbacon / home-automation

5 stars 0 forks source link

FHEM notes #17

Open sebbacon opened 2 years ago

sebbacon commented 2 years ago

I've got it working with this configuration:

define CUL_0 CUL /dev/ttyACM0@9600 1034
attr CUL_0 rfmode MAX
# The last field is a hash specific to my CUL device (cube). It relates to 
# how the TRVs were paired ("teaching-in") with the cube but at the time of writing
# I don't recall how this worked
define cm CUL_MAX fdbe51
attr cm IODev CUL_0

Now trying to work out how I can set week profiles. From here, I discovered the weekprofile module (full docs here):

Device-specific configuration also includes the weekProfile, e.g. the desired temperature for each day and each hour. The format is quite simple and starts with an implicit 00:00 (midnight) and ends with an implicit 24:00 (midnight next day). In between desired temperatures are specificed interleaving with hours, seperated by ,s. Temperature is specific in degrees celsius. Example:

17,06:00,21,20:00,17

will set 17 degrees from midnight to 06:00am, 21 degrees 06:00am to 20:00 (8:00pm) and then again 17 degrees until midnight. Such profiles are defined for each day (Mon, Tue, Wed, Thu, Fri, Sat, Sun) and set with the weekProfile command:

set MAX_Child1_Heating weekProfile Mon 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Tue 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Wed 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Thu 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Fri 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Sat 17,06:00,21,20:00,17 Sun 17,06:00,21,20:00,17

Supposedly there's a UI for it, but I can't work out how to make it work, other than you have to sudo apt-get install libjson-pp-perl. (source)

sebbacon commented 2 years ago

OK so conclusion

The webui eventlog doesn't work, but I can see events from the telnet interface with:

fhem> inform timer
fhem> 2022-09-19 13:04:42 CUL CUL_0 credit10ms: 3600
2022-09-19 13:04:42 CUL_MAX cm CUL_0:ok
2022-09-19 13:04:42 MAX bethroom lastTimeSync: 2022-09-19 13:04:42
2022-09-19 13:04:43 MAX bethroom valveposition: 0
2022-09-19 13:04:43 MAX bethroom 11.0
2022-09-19 13:04:43 MAX bethroom desiredTemperature: 11.0
2022-09-19 13:04:43 MAX bethroom RSSI: -63.5

I'm interested in all valvepositions, so I need to listen using notify (docs). Maybe

define recordvalve notify valveposition set lamp $EVTPART1

You can do "perl oneliners" in the notify (docs)

define recordvalve notify valveposition { fhem "set lamp $EVTPART1" }

To show them all in one (docs):

define TRVs readingsGroup <room>,<valve>,<target>,<temp>,<mode>,<battery> type=HeatingThermostat:valveposition,desiredTemperature,temperature,mode,battery

But to read them all programmatically, I think I want a script something like this (how to write scripts of doing this is to use the integrated editor)):

##############################################
# $Id: myUtilsTemplate.pm 21509 2020-03-25 11:20:51Z rudolfkoenig $
#
# Save this file as 99_myUtils.pm, and create your own functions in the new
# file. They are then available in every Perl expression.

package main;

use strict;
use warnings;

sub
myUtils_Initialize($$)
{
  my ($hash) = @_;
}

# Enter you functions below _this_ line.

sub CheckAllValves() {
  my $total = 0;
    foreach my $dev (devspec2array("room=MAX")) {
    $total = $total + ReadingsVal($dev, "valveposition", 0);
  }
  Log(0, "Total valve position is " . $total);
  if ($total > 0) {
    fhem (  "set boiler_switch on"  ); 
  } else {
    fhem (  "set boiler_switch off"  ); 
  }
}

1;

Which I could then call with:

define recordvalve notify .*valveposition.* {CheckAllValves()}

And test with

trigger livingroom.front valveposition: 80