Optimistic parameter in Home Assistant



  • Hi, the HOme Assistant documentation says that for MySensors integration you can set the 'optimistic' parameter. But how to do it? I have an MQTT gateway.



  • In your configuration.yaml add this

    mysensors:
      optimistic: true
    

    And restart home assistant



  • Doesn't work.
    Invalid config for [mysensors]: required key not provided @ data['mysensors']['gateways']. Got None. (See /config/configuration.yaml, line 175).
    Gateways I have defined in the integrations UI.



  • @Marek If you only copy and pasted the above two lines into your config, then you got that error message because it is an incomplete configuration for the old, YAML-based MySensors integration.

    A valid YAML configuration looks, or rather looked, like this:

    mysensors:
      gateways:
        - device: mqtt
          persistence_file: '/config/mysensors.json'
          topic_in_prefix: 'mysensors-out'
          topic_out_prefix: 'mysensors-in'
        - device: mqtt
          persistence_file: '/config/mysensors_testing.json'
          topic_in_prefix: 'mytest-out'
          topic_out_prefix: 'mytest-in'
      optimistic: true
      retain: true
      version: '2.3'
    

    You may be able to set the optimistic setting by adding something like this to your config and restarting Home Assistant. You may also need to delete your existing UI-based integration beforehand.

    That being said, the old YAML configurations are not recommended (and apparently neither documented) anymore. When a YAML-based MySensors configuration is detected after a HA start, it will be migrated to the new UI-based integration automatically. Subsequent changes to the YAML config will be ignored.

    AFAIK, the new UI-based intregration deprecated a bunch of configuration options and I think that the optimistic setting is one of them. I don't know of a way to set it using the UI-based integration, nor if it'll be carried over by importing an "existing" YAML config. The documentation of the MySensors integration may be incorrect / outdated here.



  • I did as you advised. I deleted Mysensors in gui. I added the configuration in configuration.yaml. After rebooting HA still does not optimistic work. There is an entry in the log: 'optimistic option for mysensors is deprecated. Please remove optimistic from your configuration file '.
    I'm afraid Home Assistant has killed the ability to use battery-operated MySensors devices.



  • No, Home Assistant didn't render battery-powered nodes unusable.

    I have never used the optimistic mode in Home Assistant, yet I'm able to achieve uptimes of more than a year with CR2032-powered (merely ~230 mAh) MySensors nodes. See here for an example. The temperature sensor I mentioned there is still working since April 2020, reporting every 5 minutes.

    In which use case would the optimistic mode be necessary?

    I mean, you have full control over the node's behavior. If you want to go as easy on the batteries as possible, you can put a node back to sleep as soon as it has sent a new measurement once, without waiting for any feedback. For more critical sensors (i.e. security-related) and actors on the other hand, you probably want confirmation that the data was successfully received and rather replace the batteries a little bit earlier, don't you?



  • Temperature measurement is not a problem. It doesn't need optimistic mode.
    I have my DIY nodes that control heating in rooms (radiators). They are battery devices. Every 5 minutes they wake up to check if the switch (S_BINARY) is turned on or not. This switch requires optimistic mode.



  • I have encountered the same situation trying to use a switch to control some blinds.
    Has there been any update on this issue from either Home Assistant or MySensors, or any workaround developed?


Log in to reply
 

Suggested Topics

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts