Skip to content

Commit

Permalink
Fix invalid device_class field in announce messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ejohb committed Jul 11, 2022
1 parent 09a639b commit 6a592a4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
33 changes: 3 additions & 30 deletions amniotic/mqtt/control.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import logging
import pip
import threading
from functools import cached_property
from time import sleep
from typing import Optional, Any

import pip
from johnnydep import JohnnyDist as Package
from paho.mqtt import client as mqtt
from pytube import YouTube, Stream
from time import sleep
from typing import Optional, Any

from amniotic.audio import Amniotic
from amniotic.config import NAME
Expand Down Expand Up @@ -127,7 +126,6 @@ def data(self) -> dict:
"unique_id": self.uid,
"object_id": self.uid,
"device": self.device.announce_data,
"device_class": self.HA_PLATFORM,
"force_update": True,
"payload_available": self.PAYLOAD_ONLINE,
"payload_not_available": self.PAYLOAD_OFFLINE,
Expand Down Expand Up @@ -275,23 +273,9 @@ class VolumeMaster(Volume):
Home Assistant master volume control.
"""
HA_PLATFORM = 'number'
ICON_SUFFIX = 'volume-high'
NAME = 'Master Volume'

@property
def data(self):
"""
Home Assistant announce data for the entity.
"""
data = super().data | {
'min': self.MIN,
'max': self.MAX
}
return data

def get_value(self) -> Any:
return self.amniotic.volume

Expand Down Expand Up @@ -386,17 +370,6 @@ def get_value(self) -> Any:
def set_value(self, value) -> Any:
pass

@property
def data(self):
"""
Home Assistant announce data for the entity.
"""
data = super().data
data.pop('device_class')
return data

@cached_property
def update_sensor(self):
"""
Expand Down
1 change: 0 additions & 1 deletion amniotic/mqtt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def topic_command(self):
@property
def data(self):
data = super().data
data.pop('device_class')
if self.UOM:
data['unit_of_measurement'] = self.UOM
return data
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
long_description_content_type='text/markdown',
name=name,
version=__version__,
url=f'https://github.com/fmtr/{name}',
url=f'https://link.frontmatter.ai/{name}',
license='Copyright © 2022 Frontmatter. All rights reserved.',
author='Frontmatter',
description='A multi-output ambient sound mixer for Home Assistant',
Expand Down

0 comments on commit 6a592a4

Please sign in to comment.