flukso on home assistant

home assistant and fluko!?
how can we do it?

gebhardm's picture

MQTT and Node-Red?

neomarcio's picture

i ,not a good at this things,can you explain how to do it!

gebhardm's picture

Well, firstly describe your requirement more in detail; there are so many home assistant and home automation systems out there, you will not be able to count. As such you just asked "how can I see the moon" and I answered "open your eyes"...
Well, secondly, the Flukso is a MQTT broker and publishes its readings by a bunch of MQTT messages; these may be used by "a" home assistant for whatever, if it is able to "understand" it. For understanding most likely the sent messages need to be reformatted; and such can easily be done using Node-RED.
Well, thirdly, "being not good at something" is no excuse, but should raise the wish to get better; and as such not only G**gle is your friend...

neomarcio's picture

well spoken,i not an expert on this kind of things,i´m taking the 1º steps on this kind of things,i have purchase a fluko device to measure my eletric bill and "G**gle" a video of HOMEASSISTANT!!! so i followed the instructions and install (hass.io) on a raspeberry pi 3,and i thought if i can see my flukso devise on my home assistant....well ...i...G**gle..it again and i find this(https://github.com/flukso/hass_flukso_component)...but i do every thing that i think i understand,but it doesn`t work!!!???
so my turn my thoughts to my account of flukso,trying to get help from the persons that realy understand...this things.
sorry for my english...i am portuguese,can you hel me?

gebhardm's picture

As it seem the flukso/hass-component does not comply to the latest Home Assistant installation. So, what remains is either addressing the repo owner by issue or find out yourself what needs to be changed...

20-05-26 06:40:58 INFO (MainThread) [supervisor.store.git] Update add-on https://github.com/flukso/hass_flukso_component repository
20-05-26 06:41:00 ERROR (MainThread) [supervisor.utils.json] Can't read json from /data/addons/git/cffceb59/repository.json: [Errno 2] No such file or directory: '/data/addons/git/cffceb59/repository.json'
20-05-26 06:41:00 WARNING (MainThread) [supervisor.store.data] Can't read repository information from /data/addons/git/cffceb59/repository.json

gebhardm's picture

Note: Just did some crawling through the repo; the flukso add-on works with FLM03 only; it does not recognize FLM02 configurations, thus does not work with it without adaptations.

neomarcio's picture

well mine is that FLM02

tld's picture

neomarcio: What I did was point the HA mqtt to my model FLM02B flukso box

in the HA configuration.yaml file

mqtt:
broker: [ip address of your flukso box]
port: [mqtt port on flukso box, default 1883?]

sensor:
-platform: mqtt
name: "[whatever you want to call your sensor]"
state_topic: "/sensor/[flukso sensor id]/gauge"
unit_of_measurement: "W"
value_template: '{{ value_json[1] }}'

--

the rest you will have to figure out yourself, I did this ages ago so I don't remember where I found it, you can create extra sensor entries for additional flukso sensors, and it might get broken with further HA upgrades

Doing this has limitations, and probably is not the most elegant way to do it, you will need to bridge mqtt servers if needed

tld's picture

I forgot the important bit in the configuration.yaml file

sensor:
- platform: template
sensors:
energy_consumption:
value_template: '{{ "%0.1f"|format(states.sensor.pvoutput.attributes.energy_consumption|float/1000) }}'
friendly_name: 'Consumption'
unit_of_measurement: 'kWh'
energy_generation:
value_template: '{% if is_state_attr("sensor.pvoutput", "energy_generation", "NaN") %}0{% else %}{{ %0.2f"|format(states.sensor.pvoutput.attributes.energy_generation|float/1000) }}{% endif %}'
friendly_name: 'Generated Today'
unit_of_measurement: 'kWh'

gebhardm's picture

@bertouttier - then it would be great to also make it FLM02 compliant :-) I saw that the /device/+/config/sensor topic could rather easily be made compliant providing sensor-id and name=function; the gauges and counters are the same in FLM02 and FLM03. Thanks.

bertouttier's picture

@gebhardm you are probably right. I don't own a FLM02, so I did not get to actually implement it. I am discussing with Bart on this. If you can't wait, feel free to open a PR! :)

KennyBuntinx's picture

Same here - FLM03 and can't get it to work - It complains about the yaml file .
Any help / example with a good configuration.yaml file ?

neomarcio's picture

solution...solution...

bertouttier's picture

@kennybuntinx what is your configuration? It should be as simple as:

  1. flukso:

If there are sensors that you want to ignore:

flukso:
ignore_sensors:
- # water counter
- # gas counter

If you are using the code from my PR (located here, Bart did not get around to merge it yet...), please make sure that you read the README file to know how to set up the MQTT bridge between your HA broker and the Flukso broker.

FLM02 support is not added yet, but for your FLM03 it should work. Let me know.

neomarcio's picture

i try and i try but...i can`t @££#@fuck....
can´t detect on home assistant!!!! is there no video to explain!!!!

netweaver's picture

I also tried it on my FLM02 but it doesn't seem to work (yet) even after the Oct 2020 update.
@bertouttier maybe you can have a look into making it FLM02 compliant too?
I'm happy to be your tester for this. Normally it's not my favorite role in a project but for this I make an exception...
Feed me your Python files, I'll apply and report back. If you need any other pieces of example info, let me know.

Thanks.

ps. I also made an issue for it, https://github.com/flukso/hass_flukso_component/issues/3

vk2him's picture

I have a Flukso v2 and have Home Assistant setup to read the mqqt messages that the Flukso publishes.

Mqqt is integrated into HA, so it simply needs to be enabled and configured to point to the flukso's IP address - this page give you the details:
https://www.home-assistant.io/integrations/mqtt

You then setup your sensor in configuration.yaml - note I included a value template that ensures the production value is always zero when the sun goes down. Substitute your sesor IDs from the flukso configuration page.

sensor:
- platform: mqtt
state_topic: "/sensor/1ab4d6cd9f2981bfc3a4bxxxxxxxx/gauge"
name: "fluksoconsumption"
qos: 0
unit_of_measurement: "W"
value_template: '{{ value_json[1] }}'

- platform: mqtt
state_topic: "/sensor/c7c90d029e018769b5fxxxxxxxxx/gauge"
name: "fluksoHWSconsumption"
qos: 0
unit_of_measurement: "W"
value_template: '{{ value_json[1] }}'

- platform: mqtt
state_topic: "/sensor/7ab7a73bd38767b25514ebxxxxxxx/gauge"
name: "fluksoproduction"
qos: 0
unit_of_measurement: "W"
value_template: '{% if is_state("sun.sun", "below_horizon")%}0{%else%}{{ value_json[1] }}{%endif%}'

This will create entities in Home Assistant that can be used to visualise power consumption/production - I use these two home assistant cards to visualise:

https://github.com/JonahKr/power-distribution-card
https://github.com/gurbyz/power-wheel-card

denhuff's picture

@VK2HIM
have followed your instruction, and it woks. thanks for the affort
gonna experiment with the puls sensors
state_topic: "/sensor/7ab7a73bd38767b25514ebxxxxxxx/pulse"

vk2him's picture

@Bertouttier - I couldn't get this to work with a Version 2A Flukso - I just added a comment to an existing Github issue. By the way, I had already connected to the flukso via mqtt as I described in the post above on 29th May 2021 - can yours co-exist without problems with the method I'm already using?

bollewolle's picture

I tried it out today but still get errors in the log. I think I might have a user permission issue in MQTT. Could you provide the config of the "Mosquitto broker" Add-On by any chance? One that is proven to work with the custom config you mention in your info.md file?

It seems that with my current Add-On config the info.md config for the brigde isn't sending anything to the broker. My current "Mosquitto broker" Add-On config is like so:

logins:
- username: '!secret mosquitto_username'
password: '!secret mosquitto_password'
customize:
active: true
folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false
anonymous: false

So that's not working because with the info.md bridge config I don't get anything on the broker.

If I then add a line with "user mosquitto" to the accesscontrollist, then I do get everything send to the broker, but in that case the Flukso integration is providing errors.

So I'm wondering what the sweet spot is with regards to configuration to make it all work :)
Oh, and I have an FLM02A, in case that's imporant to know.

Thanks in advance.

vk2him's picture

@Bollewolle - which Mosquitto Broker are you using? I have @Bertouttier's Home Assistant intergration working on a FLM02A and I'm using the in-builtcore Broker available from the Add-on store - it's currently version 6.0.1.

It seems you're missing a conf file needed for the bridge.

Here is my Broker configuration (from within the Add-on page)

logins: []
customize:
active: true
folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

Note I didn't create a new user login for mosquitto as it doesn't really need it, I just use my HA login.

You also need to create a directory /share/mosquitto if it doesn't already exist and put the following into mosquitto.conf - substitute your flukso's ip and reboot after saving.

connection bridge-01
address 192.168.1.73:1883
topic # out 0
topic # in 0

bollewolle's picture

I use the same Add-On yes. I've tried yesterday without the login credentials as well, but retried today. The broker does receive all the data, but still whenever I add the Flukso integration I get errors in the log (see further below). I'm sure that I'm using the correct device hash as it's exacly like what I'm seeing in MQTT Explorer under the device/ topic (so not those under sensor). I basically see the same structure in MQTT Explorer as what's shown in this screenshot on the FLM02A issue: https://github.com/bertouttier/flukso-hacs/issues/1#issuecomment-1025524998.

This one for the Sensor:
---------------------------------
Logger: homeassistant.components.sensor
Source: custom_components/flukso/discovery.py:401
Integration: Sensor (documentation, issues)
First occurred: 09:01:54 (1 occurrences)
Last logged: 09:01:54

Error while setting up flukso platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/flukso/sensor.py", line 10, in async_setup_entry
configs = get_entities_for_platform("sensor", hass.data[DOMAIN][entry.entry_id])
File "/config/custom_components/flukso/discovery.py", line 445, in get_entities_for_platform
entities.extend(_get_sensor_entities(entry_data, device_info))
File "/config/custom_components/flukso/discovery.py", line 401, in _get_sensor_entities
for sensor in entry_data["sensor"].values():
KeyError: 'sensor'

This one for the Binary Sensor:
-------------------------------------------
Logger: homeassistant.components.binary_sensor
Source: custom_components/flukso/discovery.py:287
Integration: Binary Sensor (documentation, issues)
First occurred: 09:01:54 (1 occurrences)
Last logged: 09:01:54

Error while setting up flukso platform for binary_sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/flukso/binary_sensor.py", line 10, in async_setup_entry
configs = get_entities_for_platform(
File "/config/custom_components/flukso/discovery.py", line 443, in get_entities_for_platform
entities.extend(_get_binary_sensor_entities(entry_data, device_info))
File "/config/custom_components/flukso/discovery.py", line 287, in _get_binary_sensor_entities
for sensor in entry_data["sensor"].values():
KeyError: 'sensor'

vk2him's picture

The screenshot from that github issue is from my system - can you confirm you're using the hash from the first "config" entry and not the one that has Kube ... and also confirm from HACS that you're using the Flukso integration v1.04 ?

bollewolle's picture

I can confirm yes, as I don't have a Kube. But I've just created an issue on Github to gather all the relevant information, it's probably a better place as it might rather be a code issue and not a setup issue (to be confirmed if that's the case of course). Issue can be found here: https://github.com/bertouttier/flukso-hacs/issues/2

bollewolle's picture

I'll post it here as well, but I closed the Github issue because I found the issue. I'll provide feedback for future reference.

I had set the Mosquitto Add-On to no longer be password protected but it turned out the the Mosquitto integration itself still was trying to signin with a password. Since that of course no longer was necessary, no data was being received in Home Assistant as a whole, with as a result the above issues with the Flukso integration as well. So in the end it was, as per usual, my mistake due to an oversight. But the integration is now working correctly, awesome! Thanks.

rossack's picture

I installed the flukso-hacs custom component and added an FLM03 device which works great. I then added another device which is an FLM02B (Serial FL03001249, Firmware: 250) but I get Failed to Setup message and the log file shows an error when processing the JSON object from the /device/config/sensor/ topic

  1. File "/home/homeassistant/.homeassistant/custom_components/flukso/discovery.py", line 466, in config_message_received
  2. 2022-03-25 10:27:17 ERROR (MainThread) [homeassistant.util.logging] Exception in config_message_received when handling msg on '/device/a004fa50d817516109996ed2f010329d/config/sensor' : '{"53":.........}

any suggestions?
thanks in advance.