MQTT import/export power feed to emonEVSE

I hoping someone can offer some insight, as I’m clearly doing something wrong but can’t work out what. I’m remotely supporting an emonEVSE system and trying to enable export triggered divert, but the EVSE isn’t seeing my import/export topic.

The EVSE is connected to mosquitto on Home Assistant, shows as ‘connected’ and is happily reporting it’s values to HA. I’m publishing a Home Assistant grid power feed on mqtt under the topic emon/emonpi/power1 using this automation (checked against similar forum posts)

automation:
- id: 'Import-Export feed'
  description: ''
  trigger:
  - platform: state
    entity_id:
    - sensor.shellyem_b9e0cd_channel_1_power
  condition: []
  action:
  - service: mqtt.publish
    data:
      payload_template: '{{ states.sensor.shellyem_b9e0cd_channel_1_power.state
        }}'
      topic: emon/emonpi/power1
  mode: single

The feed is published successfully as shown below, I’ve tried experimenting with adding a timestamp, adding metric etc.
image

EVSE is showing as setup for PV diversion grid import/export but isn’t getting a feed (i.e showing 0W)

image

What daft thing am I missing? Thanks in advance.

That all looks correct to me. Try setting the base-topic to emon/openevse-287c

Are you sure the EVSE is connected to the same MQTT server?

Thanks for rapid response Glyn :grin:!
It’s definitely connected to the same MQTT server as all values from the EVSE are coming in to HA and the EVSE responds to manual override.

image
In terms of base-topic you mean on the MQTT settings on the EVSE? Just double checking as I’m remote, so I’ll have to ask the user to make that change.

Have you tested that template? Developer tools → Template

The ‘correct’ way to reference the state value is to use

{{states('sensor.shellyem_b9e0cd_channel_1_power')}}

Beware if it is unavailable, emoncms will simply take the string as a null value :slight_smile:

[edit]
From the docs Templating - Home Assistant (home-assistant.io)

[edit2]
Oh, I see it is being sent correctly - sorry (good to change the template though - stops errors on startup).

Thanks for that tip Brian, I have pending a transition of all our yaml files over to the ‘modern method’ and I’ll make sure this change is part of that move, the legacy formatting still works, but I understand mixing the two causes problems. Testing locally both scripts return the same result, so as you say, I don’t think it’s the issue here.

1 Like

Not an EVSE User, but fundamentally, you usually use a different topic name in MQTT to send and receive data.

To provide data that the EVSE gets (a topic it subscribes to), should the sending system not publish the data on this base topic? The emon base topic is for sending data to emoncms (usually).

image

You cut off the top of the dialogue so don’t know what it says.

Again guessing here.

Just to feed back here that @glyn.hudson’s suggestion worked. Changing the base address on the emonEVSE interface to emon/openevse-287c resulted in the emon/emonpi/power1 feed values becoming visible on the emonevse, diversion is now working.
Thanks all for your help.