This rule template takes an energy consumption value as an input and controls a color light in the range from green to red for visualising the current consumption.
Changelog
Version 0.3
- changed to DSL script (by @kai).
Version 0.2
- adapted to the Community Marketplace (by @ysc).
Version 0.1
- initial release on the Eclipse Marketplace (by @kai)
Resources
uid: 'kaikreuzer:energymeter'
label: Energy Meter
description: Visualizes the current energy consumption.
configDescriptions:
- name: consumption
type: TEXT
context: item
filterCriteria:
- name: type
value: Number
label: Consumption Item
description: Data source for current consumption
required: true
- name: light
type: TEXT
context: item
filterCriteria:
- name: type
value: Color
label: Color Item
description: Color light to use for visualisation
required: true
- name: max
type: INTEGER
label: Max. consumption
description: Maximum value for red light
required: true
defaultValue: 1500
triggers:
- id: trigger
label: Current consumption changes
description: Triggers whenever the current consumption changes its value
configuration:
itemName: '{{consumption}}'
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: setcolor
label: Change the light color
description: >-
Sets the color to a value in the range from green (low consumption) to
red (high consumption)
configuration:
type: application/vnd.openhab.dsl.rule
script: |-
var power = (newState as Number).intValue
var percent = power / (30.0 / 100.0)
if(percent < 0) percent = 0
var hue = 120 - percent * 1.2
sendCommand({{light}}, hue +',100,100')
type: script.ScriptAction