Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Add haptic feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Greco committed Jan 29, 2021
1 parent 0b622e3 commit a70dfba
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Components/Card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ const Card = ({ }) => {
const statusColor = state === 'Printing' ? "#4caf50" : state === "unknown" ? "#f44336" : state === "Operational" ? "#00bcd4" : "#ffc107"
const borderRadius = styles[theme].borderRadius;

const fireHaptic = () => {
let event = new Event("haptic");
event.detail = "medium"
window.dispatchEvent(event);
}

const togglePower = config.power_entity ? () => {
fireHaptic();
hass.callService('homeassistant', 'toggle', { entity_id: config.power_entity })
.then((context) => {
console.log(context)
})
} : () => { };

const toggleLight = config.light_entity ? () => {
fireHaptic();
hass.callService('homeassistant', 'toggle', { entity_id: config.light_entity })
.then((context) => {
console.log(context)
Expand Down

0 comments on commit a70dfba

Please sign in to comment.