Fix hass api (#220)
* don't sent to mqtt when hass_api * fix wake_on_lan configuration
This commit is contained in:
@@ -840,9 +840,9 @@ def parse_arguments():
|
|||||||
turn_off:
|
turn_off:
|
||||||
service: mqtt.publish
|
service: mqtt.publish
|
||||||
data:
|
data:
|
||||||
topic: config.mqtt_discovery_prefix + "/update/{}/command"
|
topic: "{}/update/{}/command"
|
||||||
payload: "shutdown"
|
payload: "shutdown"
|
||||||
""".format(get_mac_address(), get_network_ip(), hostname, hostname )
|
""".format(get_mac_address(), get_network_ip(), hostname, config.mqtt_discovery_prefix, hostname )
|
||||||
print(hass_config)
|
print(hass_config)
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
@@ -926,13 +926,19 @@ def gather_and_send_info():
|
|||||||
print("Error writing to output file:", e)
|
print("Error writing to output file:", e)
|
||||||
|
|
||||||
if args.hass_api:
|
if args.hass_api:
|
||||||
|
if config.hass_host != "your_hass_host" and config.hass_token != "your_hass_token":
|
||||||
publish_to_hass_api(monitored_values)
|
publish_to_hass_api(monitored_values)
|
||||||
else:
|
else:
|
||||||
|
print("Error: Home Assistant API host or token not configured.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
if config.mqtt_host != "ip address or host":
|
||||||
if hasattr(config, 'group_messages') and config.group_messages:
|
if hasattr(config, 'group_messages') and config.group_messages:
|
||||||
bulk_publish_to_mqtt(monitored_values)
|
bulk_publish_to_mqtt(monitored_values)
|
||||||
else:
|
else:
|
||||||
publish_to_mqtt(monitored_values)
|
publish_to_mqtt(monitored_values)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
if not args.service:
|
if not args.service:
|
||||||
break
|
break
|
||||||
# Break the sleep into 1-second intervals and check stop_event after each interval
|
# Break the sleep into 1-second intervals and check stop_event after each interval
|
||||||
|
|||||||
Reference in New Issue
Block a user