- Platform information:
- Hardware:Orangepi 3 LTS
- OS: Armbian 5.15
- InfluxDB
- openHAB version: 3.4.4
I use the code developed by @masipila to control my heat pump to follow spot electricity price. I also use the script to update points in InfluxDV to control my dishwasher to start at night at the cheapest hour.
The logic goes as follows:
The script fetches the electricity spot price for tomorrow
- Prices for tomorrow are stored in InfluxDB hour by hour
- The code finds the cheapest consecutive 3 hours from the forecast
- These hours are marked in a separate InfluxDB registry as 1, the other hours are marked 0
- Every hour a script reads the current hour status, 1 or 0, from influxdb and updates a number item, dishwasherControl accordingly
- If the item status changes from 0 to 1 the dishwasher should start
This is the script that writes data to influxdb:
dh = require('test/date-helper.js');
wh = require('test/waterheater.js');
influx = require('test/influx.js');
start = dh.getMidnight('start');
stop = dh.getMidnight('stop');
// Determine cheap hours for dishwasher and washer and write control values to the database
hours = 2;
points = wh.determineHours(start, stop, hours);
influx.writePoints('dishwasher_control', points);
// Determine cheap hours for washer and write control values to the database
hours = 2;
points = wh.determineHours(start, stop, hours);
influx.writePoints('washer_control', points);
This script reads influxdb every hour and updates the dishwasherControl an washerControl items:
dh = require('sienitie18/date-helper.js');
influx = require('sienitie18/influx.js');
nyt = dh.getCurrentHour();
// update dishwasher control item
tiskikoneenOhjaus = influx.getCurrentControl('dishwasher_control',nyt);
console.log("Tiskikoneen ohjaus: " + tiskikoneenOhjaus);
items.getItem("dishwasherControl").postUpdate(tiskikoneenOhjaus);
// update washer control item
pesukoneenOhjaus = influx.getCurrentControl('washer_control',nyt);
console.log("Pesukoneen ohjaus: " + pesukoneenOhjaus);
items.getItem("washerControl").postUpdate(pesukoneenOhjaus);
I have a rule that is triggered when item dishwasherControl changes to 1:
configuration: {}
triggers:
- id: "3"
configuration:
itemName: dishwasherControl
state: "1"
type: core.ItemStateChangeTrigger
conditions:
- inputs: {}
id: "6"
configuration:
itemName: Siemens_Astianpesukone_012020388740013427_Operation_State
state: Run
operator: "!="
type: core.ItemStateCondition
actions:
- inputs: {}
id: "4"
configuration:
itemName: Siemens_Astianpesukone_012020388740013427_Virta
command: ON
type: core.ItemCommandAction
- inputs: {}
id: "2"
configuration:
itemName: Siemens_Astianpesukone_012020388740013427_Selected_Program
command: Dishcare.Dishwasher.Program.Auto2
type: core.ItemCommandAction
- inputs: {}
id: "5"
configuration:
itemName: Siemens_Astianpesukone_012020388740013427_Program_Actions
command: start
type: core.ItemCommandAction
- inputs: {}
id: "1"
configuration:
itemName: Siemens_Astianpesukone_012020388740013427_Program_Actions
command: start
type: core.ItemCommandAction
The problem
If I change the item dishwasherControl status manually by running the following single line script, the dishwasher starts
items.getItem("dishwasherControl").postUpdate("1");
However, if dishwasherControl is updated by the script above the script is not triggered. Analysis of dishwasherControl shows, that the item value has been updated at 4 AM last night:
Dishwasher did not start.
How come updating item dishwasherControl manually triggers the rule but automatic udates do not?