Skip to content

Commit

Permalink
Add version to 3d printer
Browse files Browse the repository at this point in the history
  • Loading branch information
sondregronas committed Jul 11, 2024
1 parent 3e954f3 commit 86ff090
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions custom_components/ankermake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def td_convert(seconds):
return self.coordinator.ankerdata.get_api_service_online(key.split('=')[1])
elif key.startswith('%SVC_STATE='):
return self.coordinator.ankerdata.get_api_service_status(key.split('=')[1])
elif key.startswith('%VERSION='):
return self.coordinator.ankerdata.get_api_version_value(key.split('=')[1])
elif key.startswith('%CFG='):
return self.coordinator.config[key.split('=')[1]]

Expand Down
3 changes: 3 additions & 0 deletions custom_components/ankermake/ankermake_mqtt_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ def _remove_error(self):
def api_service_possible_states(self) -> list:
return list(self._api_status.get('possible_states', {}).keys()) + ['Unavailable']

def get_api_version_value(self, key: str) -> str:
return self._api_status.get('version', {}).get(key, 'Unavailable')

def get_api_service_status(self, service: str) -> str:
return self._api_status.get('services', {}).get(service, {}).get('state', 'Unavailable')

Expand Down
2 changes: 2 additions & 0 deletions custom_components/ankermake/sensor_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ def __init__(self, *args, **kwargs):
'error_level': 'error_level',
'config_host': '%CFG=host',
'config_name': '%CFG=printer_name',
'api_version': '%VERSION=api',
'octoprint_version': '%VERSION=server',
}
],
# Hotend Sensor
Expand Down

0 comments on commit 86ff090

Please sign in to comment.