diff --git a/docs/CLIMATE.md b/docs/CLIMATE.md index 3674b52a..e0b144a5 100644 --- a/docs/CLIMATE.md +++ b/docs/CLIMATE.md @@ -12,8 +12,7 @@ _Please note that the device_code field only accepts positive numbers. The .json **name** (Optional): The name of the device
**unique_id** (Optional): An ID that uniquely identifies this device. If two devices have the same unique ID, Home Assistant will raise an exception.
**device_code** (Required): .... (Accepts only positive numbers)
-**controller_send_service** (Required): The service that will be used to send the commands. Only `broadlink_send_packet` (Broadlink controller) and `mqtt.publish` is currently supported.
-**controller_command_topic** (Optional): MQTT topic on which to send commands when *controller_send_service* is mqtt.publish
+**controller_data** (Required): The data required for the controller to function. Enter the IP address of the Broadlink device (must be an already configured device) or the MQTT topic on which to send commands.
**temperature_sensor** (Optional): *entity_id* for a temperature sensor
**humidity_sensor** (Optional): *entity_id* for a humidity sensor
**power_sensor** (Optional): *entity_id* for a sensor that monitors whether your device is actually On or Off. This may be a power monitor sensor. (Accepts only on/off states)
@@ -32,7 +31,7 @@ climate: name: Office AC unique_id: office_ac device_code: 1000 - controller_send_service: switch.broadlink_send_packet_192_168_10_10 + controller_data: 192.168.10.10 temperature_sensor: sensor.temperature humidity_sensor: sensor.humidity power_sensor: binary_sensor.ac_power @@ -49,8 +48,7 @@ climate: name: Office AC unique_id: office_ac device_code: 2000 - controller_send_service: mqtt.publish - controller_command_topic: home-assistant/office-ac/command + controller_data: home-assistant/office-ac/command temperature_sensor: sensor.temperature humidity_sensor: sensor.humidity power_sensor: binary_sensor.ac_power diff --git a/docs/FAN.md b/docs/FAN.md index 224332ce..2af2c4ab 100644 --- a/docs/FAN.md +++ b/docs/FAN.md @@ -9,8 +9,7 @@ Find your device's brand code [here](FAN.md#available-codes-for-fan-devices) and **name** (Optional): The name of the device
**unique_id** (Optional): An ID that uniquely identifies this device. If two devices have the same unique ID, Home Assistant will raise an exception.
**device_code** (Required): ...... (Accepts only positive numbers)
-**controller_send_service** (Required): The service that will be used to send the commands. Only `broadlink_send_packet` (Broadlink controller) and `mqtt.publish` is currently supported.
-**controller_command_topic** (Optional): MQTT topic on which to send commands when *controller_send_service* is mqtt.publish
+**controller_data** (Required): The data required for the controller to function. Enter the IP address of the Broadlink device or the MQTT topic on which to send commands.
**power_sensor** (Optional): *entity_id* for a sensor that monitors whether your device is actually On or Off. This may be a power monitor sensor. (Accepts only on/off states)
## Example (using broadlink controller): @@ -27,7 +26,7 @@ fan: name: Bedroom fan unique_id: bedroom_fan device_code: 1000 - controller_send_service: switch.broadlink_send_packet_192_168_10_10 + controller_data: 192.168.10.10 power_sensor: binary_sensor.fan_power ``` Make sure the broadlink switch is already installed. Go to the Home Assistant UI/dev service, find the broadlink send_packet service and copy the name of it. @@ -42,8 +41,7 @@ fan: name: Bedroom fan unique_id: bedroom_fan device_code: 2000 - controller_send_service: mqtt.publish - controller_command_topic: home-assistant/bedroom-fan/command + controller_data: home-assistant/bedroom-fan/command power_sensor: binary_sensor.fan_power ``` diff --git a/docs/MEDIA_PLAYER.md b/docs/MEDIA_PLAYER.md index 4a74d01c..12892c62 100644 --- a/docs/MEDIA_PLAYER.md +++ b/docs/MEDIA_PLAYER.md @@ -9,8 +9,7 @@ Find your device's brand code [here](MEDIA_PLAYER.md#available-codes-for-tv-devi **name** (Optional): The name of the device
**unique_id** (Optional): An ID that uniquely identifies this device. If two devices have the same unique ID, Home Assistant will raise an exception.
**device_code** (Required): ...... (Accepts only positive numbers)
-**controller_send_service** (Required): The service that will be used to send the commands. Only `broadlink_send_packet` (Broadlink controller) and `mqtt.publish` is currently supported.
-**controller_command_topic** (Optional): MQTT topic on which to send commands when *controller_send_service* is mqtt.publish
+**controller_data** (Required): The data required for the controller to function. Enter the IP address of the Broadlink device or the MQTT topic on which to send commands.
**power_sensor** (Optional): *entity_id* for a sensor that monitors whether your device is actually On or Off. This may be a power monitor sensor. (Accepts only on/off states)
## Example (using broadlink controller): @@ -27,7 +26,7 @@ media_player: name: Living room TV unique_id: living_room_tv device_code: 1000 - controller_send_service: switch.broadlink_send_packet_192_168_10_10 + controller_data: 192.168.10.10 power_sensor: binary_sensor.tv_power ``` Make sure the broadlink switch is already installed. Go to the Home Assistant UI/dev service, find the broadlink send_packet service and copy the name of it. @@ -42,8 +41,7 @@ media_player: name: Living room TV unique_id: living_room_tv device_code: 2000 - controller_send_service: mqtt.publish - controller_command_topic: home-assistant/living-room-tv/command + controller_data: home-assistant/living-room-tv/command power_sensor: binary_sensor.tv_power ``` diff --git a/smartir/climate.py b/smartir/climate.py index b542807a..73cbb35b 100644 --- a/smartir/climate.py +++ b/smartir/climate.py @@ -26,8 +26,7 @@ CONF_UNIQUE_ID = 'unique_id' CONF_DEVICE_CODE = 'device_code' -CONF_CONTROLLER_SEND_SERVICE = "controller_send_service" -CONF_CONTROLLER_COMMAND_TOPIC = "controller_command_topic" +CONF_CONTROLLER_DATA = "controller_data" CONF_TEMPERATURE_SENSOR = 'temperature_sensor' CONF_HUMIDITY_SENSOR = 'humidity_sensor' CONF_POWER_SENSOR = 'power_sensor' @@ -43,8 +42,7 @@ vol.Optional(CONF_UNIQUE_ID): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Required(CONF_DEVICE_CODE): cv.positive_int, - vol.Required(CONF_CONTROLLER_SEND_SERVICE): cv.entity_id, - vol.Optional(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, + vol.Required(CONF_CONTROLLER_DATA): cv.string, vol.Optional(CONF_TEMPERATURE_SENSOR): cv.entity_id, vol.Optional(CONF_HUMIDITY_SENSOR): cv.entity_id, vol.Optional(CONF_POWER_SENSOR): cv.entity_id @@ -96,8 +94,7 @@ def __init__(self, hass, config, device_data): self._unique_id = config.get(CONF_UNIQUE_ID) self._name = config.get(CONF_NAME) self._device_code = config.get(CONF_DEVICE_CODE) - self._controller_send_service = config.get(CONF_CONTROLLER_SEND_SERVICE) - self._controller_command_topic = config.get(CONF_CONTROLLER_COMMAND_TOPIC) + self._controller_data = config.get(CONF_CONTROLLER_DATA) self._temperature_sensor = config.get(CONF_TEMPERATURE_SENSOR) self._humidity_sensor = config.get(CONF_HUMIDITY_SENSOR) self._power_sensor = config.get(CONF_POWER_SENSOR) @@ -132,8 +129,7 @@ def __init__(self, hass, config, device_data): self.hass, self._supported_controller, self._commands_encoding, - self._controller_send_service, - self._controller_command_topic) + self._controller_data) async def async_added_to_hass(self): """Run when entity about to be added.""" diff --git a/smartir/controller.py b/smartir/controller.py index 6200c37e..1f3f19c9 100644 --- a/smartir/controller.py +++ b/smartir/controller.py @@ -21,7 +21,7 @@ MQTT_COMMANDS_ENCODING = [ENC_RAW] class Controller(): - def __init__(self, hass, controller, encoding, service, topic=None): + def __init__(self, hass, controller, encoding, controller_data): if controller not in [ BROADLINK_CONTROLLER, XIAOMI_CONTROLLER, MQTT_CONTROLLER]: raise Exception("The controller is not supported.") @@ -40,16 +40,10 @@ def __init__(self, hass, controller, encoding, service, topic=None): raise Exception("The encoding is not supported " "by the mqtt controller.") - if not topic: - raise Exception("controller_command_topic must be " - "specified for mqtt controllers.") - self.hass = hass - self._service_domain = split_entity_id(service)[0] - self._service_name = split_entity_id(service)[1] - self._command_topic = topic self._controller = controller self._encoding = encoding + self._controller_data = controller_data async def send(self, command): if self._controller == BROADLINK_CONTROLLER: @@ -73,20 +67,19 @@ async def send(self, command): "Pronto to Base64 encoding") service_data = { + 'host': self._controller_data, 'packet': command } await self.hass.services.async_call( - self._service_domain, self._service_name, - service_data) + 'broadlink', 'send', service_data) if self._controller == MQTT_CONTROLLER: service_data = { - 'topic': self._command_topic, + 'topic': self._controller_data, 'payload': command } await self.hass.services.async_call( - self._service_domain, self._service_name, - service_data) \ No newline at end of file + 'mqtt', 'publish', service_data) \ No newline at end of file diff --git a/smartir/fan.py b/smartir/fan.py index d1496274..3161ca38 100644 --- a/smartir/fan.py +++ b/smartir/fan.py @@ -25,16 +25,14 @@ CONF_UNIQUE_ID = 'unique_id' CONF_DEVICE_CODE = 'device_code' -CONF_CONTROLLER_SEND_SERVICE = "controller_send_service" -CONF_CONTROLLER_COMMAND_TOPIC = "controller_command_topic" +CONF_CONTROLLER_DATA = "controller_data" CONF_POWER_SENSOR = 'power_sensor' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_UNIQUE_ID): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Required(CONF_DEVICE_CODE): cv.positive_int, - vol.Required(CONF_CONTROLLER_SEND_SERVICE): cv.entity_id, - vol.Optional(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, + vol.Required(CONF_CONTROLLER_DATA): cv.string, vol.Optional(CONF_POWER_SENSOR): cv.entity_id }) @@ -84,8 +82,7 @@ def __init__(self, hass, config, device_data): self._unique_id = config.get(CONF_UNIQUE_ID) self._name = config.get(CONF_NAME) self._device_code = config.get(CONF_DEVICE_CODE) - self._controller_send_service = config.get(CONF_CONTROLLER_SEND_SERVICE) - self._controller_command_topic = config.get(CONF_CONTROLLER_COMMAND_TOPIC) + self._controller_data = config.get(CONF_CONTROLLER_DATA) self._power_sensor = config.get(CONF_POWER_SENSOR) self._manufacturer = device_data['manufacturer'] @@ -115,8 +112,7 @@ def __init__(self, hass, config, device_data): self.hass, self._supported_controller, self._commands_encoding, - self._controller_send_service, - self._controller_command_topic) + self._controller_data) async def async_added_to_hass(self): """Run when entity about to be added.""" diff --git a/smartir/media_player.py b/smartir/media_player.py index 3e0e26cb..92854b70 100644 --- a/smartir/media_player.py +++ b/smartir/media_player.py @@ -25,16 +25,14 @@ CONF_UNIQUE_ID = 'unique_id' CONF_DEVICE_CODE = 'device_code' -CONF_CONTROLLER_SEND_SERVICE = "controller_send_service" -CONF_CONTROLLER_COMMAND_TOPIC = "controller_command_topic" +CONF_CONTROLLER_DATA = "controller_data" CONF_POWER_SENSOR = 'power_sensor' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_UNIQUE_ID): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Required(CONF_DEVICE_CODE): cv.positive_int, - vol.Required(CONF_CONTROLLER_SEND_SERVICE): cv.entity_id, - vol.Optional(CONF_CONTROLLER_COMMAND_TOPIC): cv.string, + vol.Required(CONF_CONTROLLER_DATA): cv.string, vol.Optional(CONF_POWER_SENSOR): cv.entity_id }) @@ -84,8 +82,7 @@ def __init__(self, hass, config, device_data): self._unique_id = config.get(CONF_UNIQUE_ID) self._name = config.get(CONF_NAME) self._device_code = config.get(CONF_DEVICE_CODE) - self._controller_send_service = config.get(CONF_CONTROLLER_SEND_SERVICE) - self._controller_command_topic = config.get(CONF_CONTROLLER_COMMAND_TOPIC) + self._controller_data = config.get(CONF_CONTROLLER_DATA) self._power_sensor = config.get(CONF_POWER_SENSOR) self._manufacturer = device_data['manufacturer'] @@ -133,8 +130,7 @@ def __init__(self, hass, config, device_data): self.hass, self._supported_controller, self._commands_encoding, - self._controller_send_service, - self._controller_command_topic) + self._controller_data) async def async_added_to_hass(self): """Run when entity about to be added.""" diff --git a/version.json b/version.json index be0042d1..89979689 100644 --- a/version.json +++ b/version.json @@ -1,7 +1,7 @@ { "version": "1.3.9", - "minHAVersion": "0.89.0b0", - "releaseNotes": "A new version (1.3.9) is available that is compatible with your system. Call the ``smartir.update_component`` service to update the component.", + "minHAVersion": "0.92.0b0", + "releaseNotes": "A new version (1.4.0) is available that is compatible with your system. Call the ``smartir.update_component`` service to update the component.", "files": [ "__init__.py", "climate.py",