My mapping of the MQTT payload to the SEP

edited May 2020 in API Info

Hi all,

In writing the plugin I needed to decode the relevant sections of the specification document to the payload itself. No warranties but this may be useful (I know the formatting of the JSON could be clearer) but this did the job foe me

https://1drv.ms/x/s!ArHvG7MbE1iopGMr0_EL-8nwAlsl

Comments

  • edited October 2020

    Very useful - thanks!

    For information to convert the RSSI to dBm it's {RSSI(16) - 256} = dBm value.

    configuration.yaml in Home assistant. I use NODE RED to connect to the source and subscribe all topics in the HA MQTT broker and filter on configuration.yaml

    '  - platform: mqtt

        name: "RSSI" # PAN Received Signal Strength

        state_topic: "#"

        unit_of_measurement: 'dBm'

        value_template: "{{ value_json['pan']['rssi']|int(base=16)-256 }}"

        icon: 'mdi:antenna'

      - platform: mqtt

        name: "LQI" #PAN link quality

        state_topic: "#"

        unit_of_measurement: ''

        value_template: "{{ value_json['pan']['lqi']|int(base=16) }}"

        icon: 'mdi:antenna'

  • edited October 2020

    Here are my notes on my Home Assistant configuration, just use the HA MQTT Integration and configure to your external broker (I just use the NODE RED add-on for this, but a PI or a NAS drive running Mosquito could be used. I don't filter the MQTT messages until Home Assistant, but I don't have much traffic from MQTT in my implementation. Thanks to others on here for some of the code, I just modified it a bit for a few more indications and sensors. Anyone know where in the MQTT I can find the tariff information?

     sensor:
      - platform: mqtt
        name: "MPAN" #Supply MPAN number
        state_topic: "#"
        unit_of_measurement: ''
        value_template: "{{ value_json['elecMtr']['0702']['03']['07']|int(base=10) }}"
        icon: 'mdi:flash'
      - platform: mqtt
        name: "Home Instant Electricity" #Instantaneous consumption
        state_topic: "#"
        unit_of_measurement: 'W'
        value_template: "{{ value_json['elecMtr']['0702']['04']['00']|int(base=16) }}"
        icon: 'mdi:flash'
      - platform: mqtt
        name: "Home Import Electricity" #Meter reading (import)
        state_topic: "#"
        unit_of_measurement: 'kWh'
        value_template: "{{ value_json['elecMtr']['0702']['00']['00']|int(base=16) * value_json['elecMtr']['0702']['03']['01']|int(base=16) / value_json['elecMtr']['0702']['03']['02']|int(base=16) }}"
        icon: 'mdi:gauge'
      - platform: mqtt
        name: "Home Export Electricity" #Meter reading (export)
        state_topic: "#"
        unit_of_measurement: 'kWh'
        value_template: "{{ value_json['elecMtr']['0702']['00']['01']|int(base=16) * value_json['elecMtr']['0702']['03']['01']|int(base=16) / value_json['elecMtr']['0702']['03']['02']|int(base=16) }}"
        icon: 'mdi:gauge'
      - platform: mqtt
        name: "Home Daily Electricity" #Consumption so far today
        state_topic: "#"
        unit_of_measurement: 'kWh'
        value_template: "{{ value_json['elecMtr']['0702']['04']['01']|int(base=16) * value_json['elecMtr']['0702']['03']['01']|int(base=16) / value_json['elecMtr']['0702']['03']['02']|int(base=16) }}"
        icon: 'mdi:gauge'
      - platform: mqtt
        name: "Home Weekly Electricity" #Consumption so far this week
        state_topic: "#"
        unit_of_measurement: 'kWh'
        value_template: "{{ value_json['elecMtr']['0702']['04']['30']|int(base=16) * value_json['elecMtr']['0702']['03']['01']|int(base=16) / value_json['elecMtr']['0702']['03']['02']|int(base=16) }}"
        icon: 'mdi:gauge'
      - platform: mqtt
        name: "Home Monthly Electricity" #Consumption so far this Month
        state_topic: "#"
        unit_of_measurement: 'kWh'
        value_template: "{{ value_json['elecMtr']['0702']['04']['40']|int(base=16) * value_json['elecMtr']['0702']['03']['01']|int(base=16) / value_json['elecMtr']['0702']['03']['02']|int(base=16) }}"
        icon: 'mdi:gauge'
      - platform: mqtt
        name: "RSSI" # PAN Received Signal Strength
        state_topic: "#"
        unit_of_measurement: 'dBm'
        value_template: "{{ value_json['pan']['rssi']|int(base=16)-256 }}"
        icon: 'mdi:antenna'
      - platform: mqtt
        name: "LQI" #PAN link quality
        state_topic: "#"
        unit_of_measurement: ''
        value_template: "{{ value_json['pan']['lqi']|int(base=16) }}"
        icon: 'mdi:antenna'
    
    
  • ui-lovelace.yaml

              - type: glance
                title: Octopus Energy
                columns: 3
                entities:
                - entity: sensor.home_instant_electricity
                  name: Now
                - entity: sensor.home_import_electricity
                  name: Import Reading
                - entity: sensor.home_export_electricity
                  name: Export Reading
                - entity: sensor.home_daily_electricity
                  name: Today
                - entity: sensor.home_weekly_electricity
                  name: This Week
                - entity: sensor.home_monthly_electricity
                  name: This Month
                - entity: sensor.mpan
                  name: MPAN Number
                - entity: sensor.rssi
                  name: PAN RSSI
                - entity: sensor.lqi
                  name: Link Quality          
    
              - type: horizontal-stack
                cards:
                  - type: gauge # Gauge graphic
                    name: Octopus Energy
                    entity: sensor.home_instant_electricity
                    unit: W
                    severity:
                      green: -2000
                      yellow: 0
                      red: 10000
                    min: -2000
                    max: 25000
    
    
  • automation.yaml

    #-------------------------- Notification of high energy consumption ----------
    
    - alias: High Energy Consumption
      initial_state: true
      trigger:
        platform: numeric_state
        entity_id: sensor.home_instant_electricity
        above: 10000
      action:
        - service: notify.alexa_media
          data:
            target:
              - media_player.study
              - media_player.lounge_3
              - media_player.justin_s_echo_dot
              - media_player.echo_show_8
            data:
              type: announce
            message: Electricity Consumption is above 10 kilowatts
        - delay:
            seconds: 3600
    
    
Sign In or Register to comment.