Monitor your Generac generator with Home Assistant

@lmamakos, have you updated your generator.yaml for the new mqtt format?

I did, based on the work that @gregmac did that was described in an earlier post Monitor your Generac generator with Home Assistant - #111 by gregmac That one might be worth taking a look at. His has the advantage of a more “standrd” MQTT topic string since I have some local naming conventions here that are occasionally confusing.

Hi all - I’m thrilled with this integration, and building on both @gregmac and @lmamakos work have my genmon pi fully integrated with my HA setup!

@gregmac I’m still learning the recent updates to HA, and one of your instructions was to add the generator-dashboard.yaml contents/file into my HA dashboard. I’ll be darned if i can figure out how to do that… I have plenty of dashboards that i have created, but i think i’m missing an important step in how to integrate this code into either a new or existing dashboard.

I worked with @flowersrj on this a bit over on /r/homeassistant (Reddit…)

I have a “working” setup where I monitor a 14kW Champion HSB via an HTTP REST endpoint their transfer switch provides (just like @GlennHA suggested). I say “working”, because their transfer switch only runs the wireless in AP mode, and you have to join to it as a client in order to access the API endpoint. This complicates things since you can’t have the generator or transfer switch live on your own network, and you have to have a minimum of two network interfaces. And heaven help you if your main network subnet matches theirs (192.168.0.0/24)

If you can get past the Linux networking side of things (assuming you are using Linux) to reliably join their janky wifi solution and do HTTP requests from your HA server to the transfer switch endpoint (at http://192.168.0.90/get_info, then it’s just a simple rest integration:

rest:
  - scan_interval: 60
    resource: http://192.168.0.90/get_info
    sensor:
      - name: "ATS_Event"
        value_template: "{{ value_json.ATS_Event }}"
      - name: "ATS_GEN_AC_Freq"
        value_template: "{{ int(value_json.ATS_GEN_AC_Freq) }}"
        unit_of_measurement: "Hz"
      - name: "ATS_Load_ACA_L1"
        value_template: "{{ float(value_json.ATS_Load_ACA_L1) }}"
        unit_of_measurement: "A"
      ... and many more ...

The transfer switch returns vanilla JSON, and the full set of possible values is this (my realtime values included for type determination):

$> $ curl -s 192.168.0.90/get_info | jq
{
  "controller_ID": "000000000578",
  "Gen_ACV_L12": "0",
  "Gen_Freq": "0",
  "Gen_Battery_Volt": "26.2",
  "Gen_RunHr_Minute": "32",
  "Gen_RunHr_Hour": "0",
  "Production_Date": "2000-10-10",
  "Gen_Crank_Total_Attempts": "8",
  "Gen_A_Set_Lit": "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
  "Gen_B_Set_Lit": "1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0",
  "Gen_Maintain_Minute": "30",
  "Gen_Maintain_Hour": "99",
  "Gen_Relay_Output": "0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0",
  "Gen_Digital_Input": "0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
  "Gen_DIP_Switch_A": "0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0",
  "Gen_DIP_Switch_B": "1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
  "Gen_System_Status": "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
  "Gen_Err_Flag": "GENSET_STOP",
  "Gen_Tracking_Record": "WAITE CRANK STATE",
  "ATS_Control_TIMER": "0,1,0,1,1,0,1,1,0,0,0,0,0,0,0,0",
  "ATS_Util_ACV_RN": "121",
  "ATS_Util_ACV_SN": "122",
  "ATS_Util_ACV_RS": "244",
  "ATS_Util_AC_Freq": "61",
  "ATS_GEN_ACV_UN": "0",
  "ATS_GEN_ACV_VN": "0",
  "ATS_GEN_ACV_UV": "0",
  "ATS_GEN_AC_Freq": "0.0",
  "ATS_Load_ACV_L12": "242",
  "ATS_Load_ACA_L1": "7.3",
  "ATS_Load_ACA_L2": "0.0",
  "ATS_Load_L1N_KW": "0.8",
  "ATS_Load_L2N_KW": "0.0",
  "ATS_Load_Total_KW": "0.8",
  "ATS_Load_L1N_KVA": "0.8",
  "ATS_Load_L2N_KVA": "0.0",
  "ATS_Load_Total_KVA": "0.8",
  "ATS_System_Status": "AUTO_STANDBY_MODE",
  "ATS_LIT_A": "0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0",
  "ATS_LIT_B": "0,1,1,0,0,0,0,0,1,1,0,1,0,0,0,0",
  "ATS_DIP_A_Status": "0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0",
  "ATS_DIP_B_Status": "1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0",
  "ATS_DIP_C_Status": "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
  "ATS_Util_Power_Status": "0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0",
  "ATS_Relay": "0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0",
  "ATS_System_Datetime": "2022-10-19 11:40:41",
  "ATS_System_Week": "2",
  "ATS_Load_Shed_Relay": "1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0",
  "ATS_Event": "UTILITY_TAKE_LOAD",
  "ATS_Gen_Power_Status": "0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0",
  "Load_Shed_Relay0_Demand": "1.2",
  "Load_Shed_Relay1_Demand": "1.2",
  "Load_Shed_Relay2_Demand": "1.2",
  "Load_Shed_Relay3_Demand": "1.1",
  "Load_AC2_Demand": "1.2",
  "Load_AC1_Demand": "1.2",
  "Day_Light_Saving_Setting": "1",
  "Maintainess_Time_Setting": "100",
  "Exercise_Attempts_Setting": "1",
  "Exercise_Week_Setting": "3",
  "Exercise_Time_Setting": "11:00",
  "Gen_Execute_Cloud_Command": "0",
  "Genset_Software_Reversion": "01.03",
  "ATS_Software_Reversion": "01.01"
}

Like I said, all this information is over on /r/homeassistant, but hey, maybe it’ll help somebody here.

This generator (well, all the Champion standby gensets with the wifi transfer switch) is enough of a pain to integrate that I doubt we will see real python integrations. At least it’s just a simple rest integration I guess?

I’m hoping this thread is still active for some very basic questions.

Starting point:
Genmon is up and running:
image

The MQTT Integration Add-on active on my Genmon server

MQTT server address set to the IP of my Home Assistant server. Is that correct?
I replaced the root topic “19916” with “Home”

I tried using the MQTT Explorer to see what was going on:

192.168.1.4 is the IP of my Genmon server. the connection fails.

Nothing much in the Mosquitto Broker log

HA MQTT Broker listening to Home:

I think this is user authentication related, but since this is my forst foray into MQTT, I really don’t have a clue.

Suggestions appreciated. Thanks!

On the last screen, try listening to topic Home/# where the # character is an MQTT wildcard for the topic pathname. It will match all of the remaining path componetns. (And while we’re at it, a + will match one component between / characters in the topic name.).

Setting that wildcard should show you all the messages published to the MQTT broker “under” Home/. That should at least let you see the messages going by, and confirm that the topics each of the messages are published to match what you have configured in your MQTT sensors.

1 Like

MQTT Explorer needs the IP of where your MQTT server is; in your case the IP of your Home Assistant instance.

1 Like

Thanks for the response. forging ahead:

Home/# … find a proper topic, but no answer

Setting Host to my HA server IP address: “disconnected” I’ve tried with and without Validate certificate

Gemon MQTT specifies my HA server:

Also I am on HA Core 2022.12.6

image

image

I’m not understanding what:

Please move the configuration to the mqtt integration key and restart Home Assistant to fix this issue.

is directing me to change.

thanks for your suggestions.

You might take a look at the github repo referenced in a earlier post https://community.home-assistant.io/t/monitor-your-generac-generator-with-home-assistant/62701/111?u=lmamakos for on revised configuration using the new technique.

Here’s my latest version, converted to the “new” MQTT sensor platfom that you could adapt:

################################################################
## Package / Generator
################################################################
#
#  Version 0.6
#
#  (This file is used as a "package" within the Home Assistant
#  configuration files.  If you don't use packages with your Home
#  Assistant configuration files, you need only take the relevant
#  sections of this file and add them to where you define
#  sensors, binary_sensors, etc.)

#  This package is used to interwork with (only) Generac-brand standby
#  generator systems with Nexus, Evolution and H100 controllers, also
#  using the open-source "genmon" package.  This package typically
#  runs on a dedicated Raspberry Pi (2, 3 or Zero) and is connected
#  via a serial cable to the controller located inside the generator
#  cabinet.  See:

#     https://github.com/jgyates/genmon

#  for additional information about genmon, how it works and what's
#  required to implement it.  Thanks very much to the author for a
#  quite complete and featureful monitoring system that can send
#  email, SMS notifications and many other things!

#  The genmon package consists of a number of components, the primary
#  one being the actual Python script that communicates with the
#  generator using a ModBus protocol.

#  In practice, this means running the genmon.py and genserv.py (web
#  server) daemons on the Raspberry Pi connected to the generator.

#  Among the optional components is a daemon which can monitor
#  the generator via genmon, and publish relevant information to
#  MQTT topics.  You can enable this MQTT genmon component using
#  the genmon web UI.  Of note: you'll need to ensure that the
#  MQTT topics match what's configured as topics in this file.

#  This module implements a means to collect this data without
#  requiring a custom component, or additional software that needs to
#  run.  This uses a number of MQTT sensors and jinga2 templates to
#  receive the published data and expose them as sensor entities in
#  Home Assistant.

#  Note that the MQTT topics in this file all have a "19916/" prefix
#  specified on the otherwise default MQTT topics that genmon would
#  use.  The only reason this is present is to match the local
#  convention that I happen to use personally, and ought not to be
#  considered any kind of recommendation.  Likely, you'll want to just
#  remove that prefix when adapting this configuration for your own
#  purposes.

#  genmon MQTT flushes out MQTT updated every 60 seconds.  You can choose
#  to have MQTT sensors for any or all of these data.  Note that some
#  of the published data changes rather often, such as wifi RSSI,
#  uptime counters, etc.  You might want to configure your recorder
#  component to not store those values to avoid needlessly bloating
#  the recorder database with historically uninteresting data.

#  The MQTT configuration presumes that you have the "JSON Numerics"
#  configuration switch turned OFF in the genmon MQTT configuration.
#  If you need this enabled for other reasons, then you'll need to
#  select an alternative topic with the "/value" suffix appended for
#  a number of the MQTT sensors that are defined.  These are present
#  below in the configure, but commented out.  You'll need to
#  manually switch the topics in this circumstance.

#  note that the unique_id values in this file are not signficant (or
#  even required at all).  They exist so that the entities show up
#  within the Home Assistant configuration GUI for customization.  I
#  chose to use UUIDs because it was an easy source of unique values,
#  no harm would likely come from using these same values or any that
#  you choose from on your own.

#  Louis Mamakos <[email protected]>
#  28 May 2021

################################################
## Customize
################################################

homeassistant:
  customize:
    ################################################
    ## Node Anchors
    ################################################

    package.node_anchors:
      customize: &customize
        package: 'generator'

    ################################################
    ## generator customization
    ################################################
    binary_sensor.genmon_power_outage:
      friendly_name: 'Generator Power Outage'

    sensor.genmon_outage_status:
      friendly_name: 'Generator Status'

    sensor.genmon_outage_utility_voltage:
      friendly_name: 'Generator Utility Voltage'

    sensor.genmon_generator_battery:
      friendly_name: 'Generator Battery Voltage'

    sensor.genmon_generator_rpm:
      friendly_name: 'Generator RPM'

    sensor.genmon_generator_frequency:
      friendly_name: 'Generator Frequency'

    sensor.genmon_generator_output_voltage:
      friendly_name: 'Generator Output Voltage'

    sensor.genmon_generator_output_current:
      friendly_name: 'Generator Output Current'

    sensor.genmon_generator_output_power:
      friendly_name: 'Generator Output Power'

    sensor.genmon_generator_last_alarm_log:
      friendly_name: 'Generator Last Alarm'

    sensor.genmon_generator_last_service_log:
      friendly_name: 'Generator Last Service Log'

    sensor.genmon_generator_last_action:
      friendly_name: 'Generator Last Action'

    sensor.genmon_generator_capacity:
      friendly_name: 'Generator Capacity'

    sensor.genmon_generator_exercise_time:
      friendly_name: 'Generator Exercise Time'

    sensor.genmon_mon_cpu_temperature:
      friendly_name: 'Generator CPU Temperature'

    sensor.genmon_mon_uptime:
      friendly_name: 'Generator Monitor Uptime'

    sensor.genmon_mon_load:
      friendly_name: 'Generator Monitor Load'

    sensor.genmon_outage_summary:
      friendly_name: 'Generator Outage Summary'


################################################
## generator sensors
################################################

#
#  The MQTT topics need to match what's transmitted by the
#  genmon host.  I use a non-standard MQTT prefix of '19916/' to
#  conform with the convention that I happen to use with my own
#  home automation system.
#
sensor:
  - platform: filter
    unique_id: "f0231fdf-7f1c-4acf-ad8d-c4245b722321"
    name: Genmon Generator Battery
    entity_id: sensor.genmon_generator_battery_raw
    filters:
      - filter: time_throttle
        window_size: "00:15"

  - platform: filter
    unique_id: "25046a19-4cf0-45d2-8834-cedde8b6a3dc"
    name: Genmon Mon CPU Temperature
    entity_id: sensor.genmon_mon_cpu_temperature_raw
    filters:
      - filter: time_throttle
        window_size: "00:10"
mqtt:
  sensor:
    - name: Genmon Outage Status
      unique_id: "fd8f8c07-7d6f-4aea-92b5-16b7d8acc66b"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      state_topic: '19916/generator/Outage/Status'

    - name: Genmon Outage Utility Voltage
      unique_id: "f565fed6-8a19-49d4-8066-4015c5ca91b1"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      state_topic: '19916/generator/Outage/Utility Voltage'
      # state_topic: '19916/generator/Outage/Utility Voltage/value'   # if JSON numerics
      value_template: '{{ value | regex_replace(" V", "") | float | round(0) }}'
      unit_of_measurement: "VAC"

    # status related sensors
    - name: Genmon Generator Battery Raw
      unique_id: "713eb4b9-feec-4425-8c83-84a9f486aae7"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      state_topic: '19916/generator/Status/Engine/Battery Voltage'
      # state_topic: '19916/generator/Status/Engine/Battery Voltage/value'   # if JSON numerics
      unit_of_measurement: "V"
      value_template: '{{ value | regex_replace(" V", "") | float | round(1) }}'


    - name:  Genmon Generator RPM
      unique_id: "f3a8aedd-206b-4e5f-baa9-677496ee8d3c"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      unit_of_measurement: "RPM"
      state_topic: '19916/generator/Status/Engine/RPM'
      # state_topic: '19916/generator/Status/Engine/RPM/value'    # if JSON numerics
      value_template: '{{ value | int }}'

    - name: Genmon Generator Frequency
      unique_id: "cbdc9c28-5748-4aef-91bc-5b5ec95ed545"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      unit_of_measurement: "HZ"
      state_topic: '19916/generator/Status/Engine/Frequency'
      # state_topic: '19916/generator/Status/Engine/Frequency/value'   # if JSON numerics
      value_template: '{{ value | regex_replace(" Hz","") | float }}'

    - name: Genmon Generator Output Voltage
      unique_id: "f5f462db-e16d-4596-9bd3-232b70fa5038"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      unit_of_measurement: "VAC"
      state_topic: '19916/generator/Status/Engine/Output Voltage'
      # state_topic: '19916/generator/Status/Engine/Output Voltage/value'   # if JSON numerics
      value_template: '{{ value | regex_replace(" V","") | float | round(1) }}'

    # current measurement is garbage on 22KW product, apparently
    - name: Genmon Generator Output Current
      unique_id: "10e1def6-35fd-4922-932a-90f25abb7f29"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      unit_of_measurement: "A"
      state_topic: '19916/generator/Status/Engine/Output Current'
      # state_topic: '19916/generator/Status/Engine/Output Current/value'   # if JSON numerics
      value_template: '{{ value | regex_replace(" A","") | float | round(1) }}'

    # current measurement is garbage on 22KW product, apparently, so this value may
    # also be suspect on that model
    - name: Genmon Generator Output Power
      unique_id: "914a4e97-54a0-41e7-bbeb-a256134e5e35"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      unit_of_measurement: "W"
      state_topic: '19916/generator/Status/Engine/Output Power (Single Phase)'
      # state_topic: '19916/generator/Status/Engine/Output Power (Single Phase)/value'   # if JSON numerics
      # this is normalized to watts from kilowatts
      value_template: '{{ value | regex_replace(" kW","") | float * 1000 | round(0) }}'

    - name: Genmon Generator Last Alarm Log
      unique_id: "8cb64471-9123-48f6-b9be-15c01595981e"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      state_topic: '19916/generator/Status/Last Log Entries/Logs/Alarm Log'

    - name: Genmon Generator Last Service Log
      unique_id: "bce3182a-a525-47dc-937c-8be4e5afc619"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      state_topic: '19916/generator/Status/Last Log Entries/Logs/Service Log'

    - name: Genmon Generator Last Action
      unique_id: "bf48e972-0b96-489a-9eee-4f2030017c3f"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      state_topic: '19916/generator/Status/Last Log Entries/Logs/Start Stop Log'

      # maint related sensors
    - name: Genmon Generator Capacity
      unique_id: "bf7cbe92-2b1e-48ca-addd-df963697626c"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      state_topic: '19916/generator/Maintenance/Rated kW'
      # normalize to watts
      value_template: '{{ value | regex_replace(" *[Kk]W", "") | float * 1000 | round(1) }}'
      unit_of_measurement: 'W'

    - name: Genmon Generator Exercise Time
      unique_id: "825657b6-c67a-427a-bee9-7b6ea2182628"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      state_topic: '19916/generator/Maintenance/Exercise/Exercise Time'
      # might be nice to maybe somehow normalize this, but not sure into what date/time representation
      # value is something like:  "Weekly Sunday 17:35 Quiet Mode On"

    - name: Genmon Total Run Time
      unique_id: "41c981db-5979-4ee6-b9fb-d1ca44f83b3f"
      expire_after: 300
      state_topic: '19916/generator/Maintenance/Service/Total Run Hours'
      value_template: '{{ value | regex_replace(" +h$", "") | default(0) | float }}'
      unit_of_measurement: hours

    - name: Genmon Hardware Version
      unique_id: "927b24b7-772d-434a-8fa1-4f1c5549c90d"
      expire_after: 300
      state_topic: '19916/generator/Maintenance/Service/Hardware Version'

    - name: Genmon Firmware Version
      unique_id: "4cf182de-c37b-48c9-8727-75e1f5053d0d"
      expire_after: 300
      state_topic: '19916/generator/Maintenance/Service/Firmware Version'

    # genmon monitor related sensors
    - name: Genmon Mon CPU Temperature Raw
      unique_id: "792c8096-84a3-4870-ac23-8cc5dcc8f8f0"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      unit_of_measurement: "°F"
      device_class: temperature
      state_topic: '19916/generator/Monitor/Platform Stats/CPU Temperature'
      value_template: '{{ value | regex_replace(" F","") | float | round(0) }}'

    - name: Genmon Mon Uptime
      unique_id: "7c398cb0-43bf-469b-b49f-ae8b526cac32"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      # maybe parse this out into minutes/hours?
      state_topic: '19916/generator/Monitor/Platform Stats/System Uptime'

    - name: Genmon Mon Load
      unique_id: "60b44a17-2535-47da-af10-7f6b45d35d3a"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      unit_of_measurement: '%'
      state_topic: '19916/generator/Monitor/Platform Stats/CPU Utilization'
      value_template: '{{ value | regex_replace(" *%","") | float | round(1) }}'

    - name: Genmon Version
      unique_id: "9bc1d83a-34bc-4a1e-a643-3c0eb62501dd"
      expire_after: 300
      state_topic: '19916/generator/Monitor/Generator Monitor Stats/Generator Monitor Version'

    # note that these following  are unique to my own specific situation and
    # are values collected from 1-wire bus temperature sensors connected to the Raspberry
    # Pi running genmon.  These do not come from the standard generator controller or
    # the on-board temperature sensor in the Raspberry Pi ARM CPU.  You should omit
    # these sensors if you're adapting my file for your own purposes.

    - name: Genmon 1W Controller Box
      unique_id: "882cb971-bf3e-4281-a158-bf0d0e3eb4ea"
      expire_after: 600
      unit_of_measurement: °F
      state_topic: '19916/generator/Status/External Temperature Sensors/28-00000bc56fa5'
      value_template: '{{ value | regex_replace(" *F", "") | float | round(1) }}'

    - name: Genmon 1W Outside Air
      unique_id: "1f54deef-b168-431a-aa9d-2af8e1fbf2c7"
      expire_after: 600
      unit_of_measurement: °F
      state_topic: '19916/generator/Status/External Temperature Sensors/28-020a91770670'
      value_template: '{{ value | regex_replace(" *F", "") | float | round(1) }}'

    - name: Genmon TC Generator Body
      unique_id: "8ca45d5e-91fb-4826-bc75-ea1b3d8046c4"
      expire_after: 600
      unit_of_measurement: °F
      state_topic: '19916/generator/Status/External Temperature Sensors/3b-6d800cc77f01'
      value_template: '{{ value | regex_replace(" *F", "") | float | round(1) }}'

    - name: Genmon TC Oil Cooler
      unique_id: "545c8624-4428-4791-ba95-df671b74aafe"
      expire_after: 600
      unit_of_measurement: °F
      state_topic: '19916/generator/Status/External Temperature Sensors/3b-4c880b6ac367'
      value_template: '{{ value | regex_replace(" *F", "") | float | round(1) }}'

    - name: Genmon TC Engine Body
      unique_id: "d6f20e32-04bf-4155-842f-d68346e3a68b"
      expire_after: 600
      unit_of_measurement: °F
      state_topic: '19916/generator/Status/External Temperature Sensors/3b-4c880b6ac389'
      value_template: '{{ value | regex_replace(" *F", "") | float | round(1) }}'

  binary_sensor:
      #
      #  probably the most useful sensor - are we in a power outage condition or not?
      #
    - name: Genmon Power Outage
      unique_id: "468414df-32b1-4127-8636-4202a11b880c"
      state_topic: '19916/generator/Outage/System In Outage'
      payload_off: 'No'

template:
  - sensor:
        # This particular sensor is probably a bad idea because it continuously updates
        # its value during an outage.  The convention in Home Assistant these days
        # seems to be to record a timestamp reflecting the onset of some condition,
        # and then use some sort of clever UI presentation to display the interval
        # or elapsed time.  The problem here is that this will spam the recorder database
        # (and influxdb, if you're using that component) with constantly changing values
        # while an outage is in progress.  In practice, this only happens during outages
        # while hopefully are not that frequent, so the "damage" done to these databases
        # is, in practice, minimal.  Still, this isn't a great example of how to do things,
        # though does illustrate some jinja2 template acrobatics.
      - name: generator_outage_summary
        unique_id: "11be76cc-02bc-4868-b033-5efc60a289c5"
        state: >-
          {% if states.sensor.genmon_outage_status.state | regex_match('System in outage') %}
             {% set duration = (as_timestamp(now()) - as_timestamp(states.sensor.genmon_outage_status.state)) | regex_replace('System in outage since ') | int %}
             {% set hours = duration // 3600 %}
             {% set duration = duration - hours * 3600 %}
             {% set minutes = duration // 60 %}
             {% set seconds = duration % 60 %}
             Outage active for {{ '%d:%02d:%02d' | format(hours, minutes, seconds) }}
          {% else %}
            {{ states.sensor.genmon_outage_status.state }}
          {% endif %}

automation:
  - alias: 'start power outage'
    initial_state: true
    trigger:
      - platform: state
        entity_id: binary_sensor.genmon_power_outage
        from: 'off'
        to: 'on'
        # so ideally wait a little bit for the generator to time out the utility power
        # loss, start and operate the automatic transfer switch from utility to generator
        # network equipment should be a UPS.. hopefully ISP connectivity is still working
        for:
          seconds: 45
    action:
      - service: notify.pushover_louie
        data:
          message: "Utiliy Power Loss at {{  now().strftime('%Y-%m-%d %H:%M:%S') }}"
          title: "HASS"

# maybe also initiate a zwave heal network or something after power is restored to
# from standby generator after a ~45 second interruption?  Switch back is pretty
# quick, with only a couple hundred millisecond transfer time in the ATS..

#
  - alias: end power outage
    initial_state: true
    trigger:
      - platform: state
        entity_id: binary_sensor.genmon_power_outage
        from: 'on'
        to: 'off'
    action:
      - service: notify.pushover_louie
        data:
          message: "Transfer back to utiliy power at {{  now().strftime('%Y-%m-%d %H:%M:%S') }}"
          title: "HASS"

############################################################################3
#
# Fun facts (For 22kw generac model)
#
#  Per specification, fuel consumption for propane is
#        2.56 gal/hr at 50% load (11KW)
#        3.87 gal/hr at 100% load (22KW)
#
#  Per genmon code, the 3 term polynomial to compute this is: [0, 2.74, 1.16]
#
#        gal/hr = (T0 * pctLoad^2) + (T1 * pctLoad) + T3
#        gal/hr =                    2.74 * pctLoad + 1.16
#
#  This is a pretty good fit to the spec sheet -
#       50% = 2.53 gal/hr  (vs 2.56 spec)
#      100% = 3.90 gal/hr  (vs 3.87 spec)
#
#  Home assistant could compute a gallons/hour rate in a template sensor if this seems useful.

You might look at both mine and the one referenced in the github repo in the post that I referenced. I started my work before the “JSON numerics” was a thing in genmon, so I do extra work to parse out the values that’s not required any longer if you choose to use that option.

Also, you should be seeing multiple MQTT messages going by if genmon is posting messages.

I’ve not used MQTT explorer, but one that will really screw with you is if two devices connect to the MQTT broker using the same “client ID” . If there’s a duplication, then it disconnect the other one. And they it will reconnect and zap the other, back and forth. Make sure you’re using a different client ID with MQTT explorer to avoid this, as well as with Home Assistant. (With Home Assistant, you needn’t specify one, or choose something different.)

I think the next step is to ensure that you’re seeing the messages from genmon posted to the broker and they they look reasonable. Then I’d update the Home Assistant configuration with the “new-style”.

I probably should update the first post of this thread with my new configuration, using the updated MQTT sensor definitions.

1 Like

Your 1st step is to connect to your MQTT Broker with MQTT Explorer. It seems like your broker is not up and running. If it is running, you need to add any authentication you set up.

I think others have posted the new MQTT sensors, once you verified that MQTT is working then you can make your sensor. If you can’t figure out the sensors, I or someone else can post them. There will be little differences between everyone’s, but the bulk should be identical. I created a separate MQTT.yaml just for my MQTT sensor.

1 Like

@lmamakos The v0.6 YAML file has removed all of my HA Code 2022.12.6 related messages. For now I see 26 for the MQTT Broker, all with status unavailable.
image

I didn’t make any changes to the HA Integration… these are the defaults (including a 64 character password that I do not use anywhere:

@GlennHA I didn’t specify any MQTT authentication information during setup.

On my Genmon server: I changed the MQTT server address to my Homeassistant IP address.

This is clearly where things go wrong in the Mosguitto Broker log:

2022-12-22 14:34:25: mosquitto version 2.0.11 starting
2022-12-22 14:34:25: Config loaded from /etc/mosquitto/mosquitto.conf.
2022-12-22 14:34:25: Loading plugin: /usr/share/mosquitto/go-auth.so
2022-12-22 14:34:25:  ├── Username/password checking enabled.
2022-12-22 14:34:25:  ├── TLS-PSK checking enabled.
2022-12-22 14:34:25:  └── Extended authentication not enabled.
2022-12-22 14:34:25: Opening ipv4 listen socket on port 1883.
2022-12-22 14:34:25: Opening ipv6 listen socket on port 1883.
2022-12-22 14:34:25: Opening websockets listen socket on port 1884.
2022-12-22 14:34:25: Opening ipv4 listen socket on port 8883.
2022-12-22 14:34:25: Opening ipv6 listen socket on port 8883.
2022-12-22 14:34:25: Opening websockets listen socket on port 8884.
2022-12-22 14:34:25: mosquitto version 2.0.11 running
2022-12-22 14:34:31: New connection from 127.0.0.1:37766 on port 1883.
2022-12-22 14:34:31: Client <unknown> closed its connection.
2022-12-22 14:35:16: New connection from 172.30.32.1:53473 on port 1883.
2022-12-22 14:35:16: New client connected from 172.30.32.1:53473 as **nIYpj*****pfKj5Srm3g (p2, c1, k60, u'homeassistant').
2022-12-22 14:36:05: New connection from 192.168.1.4:46495 on port 1883.
error: received null username or password for unpwd check
2022-12-22 14:36:05: Client <unknown> disconnected, not authorised.

The Genmon MQTT integration expects an MQTT Authentication Username in the form of a valid e-mail address (I tried using one of existing my homeassistant userids without success)

I know it’s very basic, but I’m not understanding how to create/specify user authentication information for MQTT.

Thanks!

So there is a username and password (Authentication). If you don’t know what the default password is, either change or if possible delete it (up to you). Utilize the username that you have of “homeassistant” in MQTT Explorer along with your password.

1 Like

Maybe poke around in the MQTT add-on and see how it does password management? I think it tries to be clever and use credentials from Home Assistant, somehow, for MQTT authentication. But I can’t really help you with specific advice here, as I’m not using the Home Assistant add-on for MQTT. I just manually run another Docker container for it (and couple dozen other services) that I manage outside of the default “supervised” HA installation.

1 Like

@lmamakos @GlennHA Thanks for the consultation.

Short story: Success!

Long story: Yes, it was an authentication issue.

I was confused by: Leave blank for no authentication

also confused by: Username must be a valid email

So… I created username = [email protected] (in HomeAssistant)
Entered that into Genmon MQTT add-on integration:

Use the username in MQTT Explorer:

image

Sensors populated in Home Assistant:

Next steps:

  • Customize genmon.yaml (0.6) for my configuration
  • Select/Customize display cards mention by several users on this thread

Also: Figure out how to get the RaspberryPi CPU temperature.

Genmon shows:

image

…but none of the Monitor readings are seen by MQTT Explorer

image

Fix: For now, change default Black List filter: Monitor,Run Time,Monitor Time,Generator Time,External Data
To: External Data

image

Thanks again!

I don’t see any Last Action log entries in MQTT Explorer:

image

…so I’m removing this entry in my genmon.yaml

    - name: Genmon Generator Last Action
      unique_id: "bf48e972-0b96-489a-9eee-4f2030017c3f"
      expire_after: 300   # genmon MQTT flushes out MQTT updated every 60 seconds
      state_topic: 'Home/generator/Status/Last Log Entries/Logs/Start Stop Log'

For my generator, genmon → Logs:

Alarm, Service and Run Logs only. No ‘Start Stop Log’

There may not have been any action since you last restarted GenMon, I would wait 2 weeks (to at least cover a auto test) to make sure.

Also, definitely wait at least your 145 mins, to ensure all other data is flushed.

I use MQTT in docker and locked my version to the one right before anonymous was removed (it is still possible, but way more difficult…so I reverted and stayed with the older version). My MQTT instance is not exposed so I don’t have a need to password protect it and I have quite of few different MQTT things going on that would have been a huge hassle to implement authentication, some being python scripts I wrote myself to use MQTT.

I think that flush interval is in seconds, if I recall correctly. Though I’m not sure where’s stored? I’d say give up until a power blip or weekly exercise run and see if something pops out.

Like Glenn, I’m also running MQTT without a password since its not on the public internet and by now there’s a dozen or two devices that would need to get reconfigured to use a password… Maybe if you’re getting started from scratch, that’s not a bad idea…

Glad to hear it’s working for you. Sorry this isn’t an easier out-of-the-box process.

Pi CPU temperature is generator/Monitor/Platform Stats/CPU Temperature

1 Like

OK… I put back the Start Stop Log and will wait for something to show up. :wink:

Ironically, just after I removed it, we had a 2 minute power interruption at 11:24 AM:
image

I received Genmon message for cranking, running, cool down…

Outdoor temp 53 degreesF last night, currently 15F.

CPU temp:
image

thanks for all the feedback,

Since I’m using mosquitto and starting at v6.0.0 they dropped support for anonymous login, creating a username/password was the easiest option for me.

No worries about the out-of-box process. I always learn more when things “go wrong”. :wink: