Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Gluwc authored Nov 26, 2019
2 parents b260c34 + 9af834f commit d314262
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,34 @@ The visibility timeout can be used in combination with a conditional card to sho

It is possible to publish to the MQTT topic using automations to update the button state using physical buttons for example (instead of using the UI button).

The payload should be published to the relevant sensor. If you sensor is named `sensor.test_button` the topic should be `homeassistant/test_button`. For more information check out the Home Assistant [documentation](https://www.home-assistant.io/docs/mqtt/discovery/).
The payload should be published to the relevant sensor. If you sensor is named `sensor.test_button` the topic should be `homeassistant/sensor/test_button/state`. For more information check out the Home Assistant [documentation](https://www.home-assistant.io/docs/mqtt/discovery/).

### Payload Example
``` json
{"timestamp":"**timestamp here**","visibility_timeout":"2 hours","visible":true,"unit_of_measurement":"timestamp"}
```
### Node Red Example
```
// Define entity_id
const entityId = "sensor.test_button";
// Get global object
const haObject = global.get("homeassistant");
// Get attributes object from entity
let payloadObject = haObject.homeAssistant.states[entityId].attributes;
// Get current timestamp in seconds
const currentTime = Math.trunc(Date.now()/1000);
// Modify timestamp in payloadObject.
payloadObject.timestamp = currentTime;
// Create string from object
msg.payload = JSON.stringify(payloadObject);
return msg;
```

## Options

Expand Down

0 comments on commit d314262

Please sign in to comment.