Curl > json command

Influxdb is a time series database, designed to store series of data, and so is much more efficient at it. MariaDB is a relational database, which is good at storing complex relationships, but at the cost of efficiency for relatively simple tasks like this.

I have not used Hassio, but I would be surprised if there isn’t an addon for Influxdb.

alright, thx.
and you have set excludes/includes for recorder, history and logbook? They wont load in my setting, and overload the system to a standstill.
If so, please would you share you’re settings there? Since you run on a Pi, that would be good reference for me!

Ive set includes /excludes for now, but am not very confident ive set them tight enough.

As i understand it those are than read by MariaDB, and the Influx would create its own db, read by grafana on another device?

Just to make clear, what is stored in the influxdb database is configured in the Influxdb component settings, and is completely independent of the history and recorder components.

I use the default sqlite rather than Mariadb and my settings are quite simple

# Enables support for tracking state changes over time.
history:

# The recorder component is storing details in a database which then are handled by the history componen
recorder:
  purge_interval: 1
  purge_keep_days: 3
  exclude:
    domains:
      - weblink
      - updater

The sqllite database file is currently 36M.

For influxdb I specify the entities I want to store

influxdb:
  host: 127.0.0.1
  username: home-assistant
  password:  !secret influxdb
  include:
    entities:
      - binary_sensor.lounge_motion_sensor
      +49 others

1 Like

thx!
I will check that out asap

Are you sure the retain flag is set? Your symptoms suggest that it isn’t.

There are addons available for both InfluxDB and Grafana at Repository: Bestlibre Addons repository. Those are the ones that I use.

yes! all other properties are retained… Ive just mailed the devs of the Iungo if this is expected behavior and if they could see on/off to be published once a minute or so.

What makes it even stranger is that is starts-off alright, and after some time suddenly the sensors are dead.

Ive even suspected my editing several automations to be the culprit, but is has roven to be the other way round. No on/off state read or resent.
Maybe my setting the recorder and logger/history options could have interfered? Ive included switches, sensors and binary_sensors, but still things went wrong this morning.

Did a reboot of the Iungo hub, and all sensors were populated again, thank goodness. Proves the code in HA is alright? or should anything here be changed:

- platform: mqtt
  name: "Tester state bin"
  state_topic: 'mac_address/powerswitch-zwave/4e6eeb01/state'
  payload_on: "on"
  payload_off: "off"
#  availability_topic: "home-assistant/window/availability"
#  payload_available: "online"
#  payload_not_available: "offline"
  qos: 1
  device_class: plug

have even changed the qos to 0, but that didnt help. wanted it to 1 just because of this behavior, what do you think?

Thanks,
Marius

ive checked that out, but it still is a bit off of a add-on… lots of finetuning still necessary. Not afraid of that, but i would love to be able to use this, to write the DB to an attached thumb.
Id probably
1- have to instruct Hassio to mount and use the thumb and then
2- instruct InfluxDB to use the thumb

using this code that seems to be an option:

This section controls where the actual shard data for InfluxDB lives and how it is flushed from the WAL. dir may need to be changed to a suitable place for you system, but the WAL settings are an advanced configuration. The defaults should work for most systems.
dir = “/var/lib/influxdb/data” The directory where InfluxDB stores the data. This directory may be changed. Note: The default directory for OS X installations is /Users/<username>/.influxdb/data Environment variable: INFLUXDB_DATA_DIR

Above is copied from their website Configure InfluxDB OSS | InfluxDB OSS v1 Documentation

So i guess what im asking is is the above correct, and if yes, whether you can help me formulate a way to implement 1 and 2 :wink:

maybe this should go to a separate thread?

Marius

Setting the retain flag would be better than sending status every minute. The state would always be correct even when Home Assistant restarts.

Not sure what you mean here. Try following the mqtt topic to see what was sent at the time the problem happens.

The mqtt binary_sensor doesn’t restore state from the recorder component. To have the correct state on startup, the retain flag must be set.

maybe you can help me with this too:

obviously i want to be able to force the HA to read the state of the switches. I thought to create some buttons to run the command_line state i use before, and an extra for the mqtt to reread.
I do that sometimes manually because the Hub itself doesn’t always show the correct state either…

my curl was:

curl -X POST -d ‘{“seq”:1, “method”:“object_prop_get”, “arguments”:{“oid”:“7b4d9b1b”, “prop”:“state”}}’ http://xxxx.xxxx/iungo/api_request

how can i transform that into a script (button)?

of course the mqtt is:

- platform: mqtt
  name: "Multi-functional state bin"
  state_topic: 'macaddress/powerswitch-zwave/7b4d9b1b/state'
  payload_on: "on"
  payload_off: "off"
#  availability_topic: "home-assistant/window/availability"
#  payload_available: "online"
#  payload_not_available: "offline"
  qos: 0
  device_class: plug
#  value_template: '{{ value.x }}'

could the be put in a script to reread somehow?

Thanks,
Marius

Not sure how that would work. I haven’t tried that myself. The easy option would be to just run InfluxDB on a separate Pi.

Probably…

yes, i know. it really is set. Ive re-checked and all other mqtt events are fine.

ive reset the log to do this, hope to shed some light somewhere

so i can safely leave it out of all includes then ? (history, logbook, recorder)

Marius

Hrm… An easier option might be to create an input_boolean to track state. You could create an automation that’s triggered by changes to the mqtt topic and sets the input_boolean accordingly. The input_boolean state would be restored on startup if you have recorder component configured. You could even add a trigger to turn the input_boolean on when power usage > 0.

o dear, this sounds way over my head right now.
`really have to let sink in what you say.

I have recorder configured (still) so thats easy :slight_smile:
the other aspects are understandably sane, automate in case of undesired behavior, and repair, but i wouldn’t know how to begin yet.
Suppose you couldn’t be tempted to give it a first shot… #fingerscrossed

HI,

been rerunning my code, could this be an issue:

i have the sensors and binary sensors for the same event, the before mentioned ones, and these:

- platform: mqtt
  state_topic: 'mac address/powerswitch-zwave/4e6eeb01/state'
  name: "Tester state"
  unit_of_measurement: "State"
#  value_template: "{{ value | round(2) }}"

Could they somehow interfere and get in a lock-up? Ive hidden these to take them out of the frontend, but they might still burden the system?

I was thinking of something like this. Note: I haven’t tested this so there might be errors…

input_boolean:
  7b4d9b1b:
    name: 7b4d9b1b

automation:
  - alias: Turn input_boolean 7b4d9b1b on
    trigger:
    - platform: mqtt
      topic: macaddress/powerswitch-zwave/7b4d9b1b/state
      payload: 'on'
    - platform: numeric_state
      entity_id: sensor.7b4d9b1b_usage
      above: 0
    action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.7b4d9b1b

  - alias: Turn input_boolean 7b4d9b1b off
    trigger:
    - platform: mqtt
      topic: macaddress/powerswitch-zwave/7b4d9b1b/state
      payload: 'off'
    action:
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.7b4d9b1b

No, shouldn’t be a problem. I have many mqtt sensors that subscribe to the same topic without any issues.

1 Like

ok cool. relief here.

wow. thats a great start, i can fill this in with all my sensors (i think)

Still, what would happen when either on or off is triggered. would they reread the value? the service turn_on or _off doesn’t actually switch anything does is?

The input_boolean will turn on if the mqtt topic receives a payload of on or if the usage sensor changes to any value that’s above 0. The input_boolean will turn off if the mqtt topic receives a payload of off. The state of the sensor will be restored from recorder component when Home Assistant starts.