Energy Meter

logo

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.2

  • adapted to the Community Marketplace (by @ysc).

Version 0.1

  • initial release on the Eclipse Marketplace (by @kai)

Resources

uid: 'demo: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/javascript
      script: |-
        var power = newState.toString().split(' ')[0]
        var percent = power / ({{max}} / 100)
        if(percent < 0) percent = 0
        var hue = 120 - percent * 1.2
        events.sendCommand('{{light}}', hue +',100,100')
    type: script.ScriptAction
1 Like