Skip to content

Regression on set_state api call #2531

@jfparis

Description

@jfparis

What happened?

A little while back I posted about a regression with the set_state api call. (issue #2464 )

Whilst some changes were made the issue is still here for me. Every time I set a state, every attribute that is equal to False or 0 will be ignored

I created a small applet below

If you run that code with version 4.5.11, you get an entity with the following attributes

rate: 0
friendly_name: Test Entity
unit_of_measurement: GBP/kWh
plunge: false
plunge_start: false

If you run it with 4.5.12 or 4.5.13 you get the following attributes

friendly_name: Test Entity
unit_of_measurement: GBP/kWh

Version

4.5.13

Installation type

Python virtual environment

Relevant log output

Relevant code in the app or config file that caused the issue

Test.yaml

test_case:
  module: test
  class: TestApp



Test.py

import appdaemon.plugins.hass.hassapi as hass

class TestApp(hass.Hass):

    def initialize(self):
        self.log("run test app")
        attributes = {
            "rate": 0,
            "friendly_name": "Test Entity",
            "unit_of_measurement": "GBP/kWh",
            "plunge": False,
            "plunge_start": False,
        }

        self.set_state(
            "sensor.test_case_sensor",
            1,
            attributes=attributes,
            replace = True,
        )


Config file

ppdaemon:
  time_zone: Europe/London
  latitude: 51
  longitude: 0
  elevation: 20
  plugins:
    HASS:
      type: hass
      ha_url: http://localhost:8123
      token: somethingsomething

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    issueSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions