I’ve been poking at this issue for about 48 hours and driving me crazy. I have a MQTT config entry topic setup and been trying get dimming to work with 0=off .5=50% and 1=100% (that’s the values the other system uses) but the brightness_scale doesn’t support floats (.01) which would have solved my issue real quick. Debating on PR for that and allowing floats? So then I saw some folks trying to get command on template to work. I get error extra keys not allowed @ data[‘command_on_template’] or on_command_type some times.
“brightness_scale”: “100”,“on_command_type”: “brightness”,“command_on_template”: “{{brightness * .01}}”
opened 02:04PM - 08 Oct 18 UTC
closed 08:46PM - 13 Oct 18 UTC
<!-- READ THIS FIRST:
- If you need additional help with this template please r… efer to https://www.home-assistant.io/help/reporting_issues/
- Make sure you are running the latest version of Home Assistant before reporting an issue: https://github.com/home-assistant/home-assistant/releases
- Do not report issues for components if you are using custom components: files in <config-dir>/custom_components
- This is for bugs only. Feature and enhancement requests should go in our community forum: https://community.home-assistant.io/c/feature-requests
- Provide as many details as possible. Paste logs, configuration sample and code into the backticks. Do not delete any text from this template!
-->
**Home Assistant release with the issue:**
<!--
- Frontend -> Developer tools -> Info
- Or use this command: hass --version
-->
0.79.3
**Last working Home Assistant release (if known):**
Never tried it on previous versions
**Operating environment (Hass.io/Docker/Windows/etc.):**
<!--
Please provide details about your environment.
-->
Official Docker image running on QNAP NAS
**Component/platform:**
<!--
Please add the link to the documentation at https://www.home-assistant.io/components/ of the component/platform in question.
-->
MQTT light
https://www.home-assistant.io/components/light.mqtt/
**Description of problem:**
mqtt light ignores **"brightness_value_template"** setting and always sends the integer brightness value alone (I'm listening in on mqtt topic). I've tried multiple combination of templates and hard-coded values - seems like it's ignored completely.
**Problem-relevant `configuration.yaml` entries and (fill out even if it seems unimportant):**
```yaml
light:
- platform: mqtt
command_topic: "/ESP_Easy0/cmd"
#state_topic: "/ESP_Easy/r2/state"
#state_value_template: "{% if value == '1' %}gpio,5,1{% else %}gpio,5,0{% endif %}"
payload_on: "WemosMotorShieldCMD,0,Forward,20"
payload_off: "WemosMotorShieldCMD,0,Stop"
on_command_type: "brightness"
brightness_command_topic: "/ESP_Easy0/cmd"
#brightness_value_template: "{{ 'WemosMotorShieldCMD,0,Forward,' ~ value_json.brightness }}"
brightness_value_template: '{{"5"}}'
```
**Traceback (if applicable):**
no exceptions or errors I could find
```
```
**Additional information:**
Apologies I thought I was clear. Looking for HA to send a value between 0-99 which represents off to on in percentage. It seems on further testing HA is indeed sending a dimmer value for my configuration. When I dim my kitchen light to 52% sure enough mqtt reflects the correct value. However 1 second later I seem to get a 99 sent over mqtt. If I use node-red to send a dimmer value, this works perfectly. Seems HA is sending “99” for “on” right after it sends the dimmer value.
2/3/2019, 8…
Sigh, It appears that key (command_on_template ) isn’t supported for json? I don’t see it in the light schema basic file. Is there a reason this wouldn’t be in MQTT vs config yaml?
DEFAULT_BRIGHTNESS_SCALE = 255
DEFAULT_NAME = "MQTT Light"
DEFAULT_OPTIMISTIC = False
DEFAULT_PAYLOAD_OFF = "OFF"
DEFAULT_PAYLOAD_ON = "ON"
DEFAULT_WHITE_VALUE_SCALE = 255
DEFAULT_ON_COMMAND_TYPE = "last"
VALUES_ON_COMMAND_TYPE = ["first", "last", "brightness"]
PLATFORM_SCHEMA_BASIC = (
mqtt.MQTT_RW_PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_BRIGHTNESS_COMMAND_TOPIC): mqtt.valid_publish_topic,
vol.Optional(
CONF_BRIGHTNESS_SCALE, default=DEFAULT_BRIGHTNESS_SCALE
): vol.All(vol.Coerce(int), vol.Range(min=1)),
vol.Optional(CONF_BRIGHTNESS_STATE_TOPIC): mqtt.valid_subscribe_topic,
vol.Optional(CONF_BRIGHTNESS_VALUE_TEMPLATE): cv.template,
vol.Optional(CONF_COLOR_TEMP_COMMAND_TEMPLATE): cv.template,
vol.Optional(CONF_COLOR_TEMP_COMMAND_TOPIC): mqtt.valid_publish_topic,
Is there a reason we don’t have command_on_template for JSON?