ThomDietrich / SenseoWifi

Wifi'ify the Senseo coffee maker. Circuit and firmware for an internal Senseo hack to monitor and control the daily coffee brew (via MQTT) ☕️📶
GNU General Public License v3.0
88 stars 23 forks source link

Implementing in Home Assistant #41

Closed Post404 closed 2 years ago

Post404 commented 3 years ago

Everything in this project has been new for me, soldering, ordering a custom PCB, dealing with firmware. I am now at the point that i'm trying to implement it into Home Assistant. It is connected to the Wifi and to the MQTT broker. I just don't know how to "translate" the OpenHAB config to Home Assistant. Is there any example available that I can see?

ThomDietrich commented 3 years ago

Hey @Post404, I was happy to read that you were able to bring your Senseo to the point where you can read its status and send commands via MQTT. Correct? Congrats!

Please provide any issue you had or details that were missing from the description. I can certainly add more content to the README of this project.


I've also recently hooked my SenseoWifi to HomeAssistant. The current firmware does not support Home Assistant auto discovery via MQTT but that is on my low prio todo list. Till then you can use the following configuration as a starting point:

If you didn't already, activate the packages concept in Home Assistant's configuration.yaml (this is not strictly linked to the below but is imho a must for all HA setups):

homeassistant:
  ...
  packages: !include_dir_named packages

Now add the following configuration file under packages/senseo_wifi.yaml:

input_boolean:
  senseowifi_brew_normal:
    name: "SenseoWifi Auslöser einfache Tasse brühen"
    initial: off
    icon: mdi:coffee

  senseowifi_brew_double:
    name: "SenseoWifi Auslöser große Tasse brühen"
    initial: off
    icon: mdi:coffee

switch:
  - platform: mqtt
    name: SenseoWifi Power
    #
    state_topic: "homie/senseo-wifi-rf21/machine/power"
    state_on: "true"
    state_off: "false"
    #
    command_topic: "homie/senseo-wifi-rf21/machine/power/set"
    payload_on: "true"
    payload_off: "false"
    #
    availability_topic: "homie/senseo-wifi-rf21/$state"
    payload_available: "ready"
    #value_template: "{{ value }}"

sensor:
  - platform: mqtt
    name: SenseoWifi Brewed size
    #
    state_topic: "homie/senseo-wifi-rf21/machine/brewedSize"
    #
    availability_topic: "homie/senseo-wifi-rf21/$state"
    payload_available: "ready"
    #value_template: "{{ value }}"

  - platform: mqtt
    name: SenseoWifi OpState
    #
    state_topic: "homie/senseo-wifi-rf21/machine/opState"
    #
    availability_topic: "homie/senseo-wifi-rf21/$state"
    payload_available: "ready"
    #value_template: "{{ value }}"

binary_sensor:
  - platform: mqtt
    name: SenseoWifi Out-of-water
    #
    state_topic: "homie/senseo-wifi-rf21/machine/outOfWater"
    payload_on: "true"
    payload_off: "false"
    #
    availability_topic: "homie/senseo-wifi-rf21/$state"
    payload_available: "ready"
    #value_template: "{{ value }}"

  - platform: mqtt
    name: SenseoWifi Brew
    #
    state_topic: "homie/senseo-wifi-rf21/machine/brew"
    payload_on: "true"
    payload_off: "false"
    #
    availability_topic: "homie/senseo-wifi-rf21/$state"
    payload_available: "ready"
    #value_template: "{{ value }}"

  - platform: mqtt
    name: SenseoWifi Cup available
    #
    state_topic: "homie/senseo-wifi-rf21/machine/cupAvailable"
    payload_on: "true"
    payload_off: "false"
    #
    availability_topic: "homie/senseo-wifi-rf21/$state"
    payload_available: "ready"
    #value_template: "{{ value }}"

  - platform: mqtt
    name: SenseoWifi Cup full
    #
    state_topic: "homie/senseo-wifi-rf21/machine/cupFull"
    payload_on: "true"
    payload_off: "false"
    #
    availability_topic: "homie/senseo-wifi-rf21/$state"
    payload_available: "ready"
    #value_template: "{{ value }}"

automation:
  - id: "1611257531404"
    alias: Regel SenseoWifi Auslöser normale Tasse brühen
    trigger:
      platform: state
      entity_id: input_boolean.senseowifi_brew_normal
      to: "on"
    action:
      - service: mqtt.publish
        data:
          topic: "homie/senseo-wifi-rf21/machine/brew/set"
          payload: "1cup"

  - id: "1611257531405"
    alias: Regel SenseoWifi Auslöser große Tasse brühen
    trigger:
      platform: state
      entity_id: input_boolean.senseowifi_brew_double
      to: "on"
    action:
      - service: mqtt.publish
        data:
          topic: "homie/senseo-wifi-rf21/machine/brew/set"
          payload: "2cup"

  - id: "1611257531406"
    alias: Regel SenseoWifi update beim Ausschalten
    trigger:
      platform: state
      entity_id: binary_sensor.senseowifi_brew
      to: "off"
    action:
      - service: input_boolean.turn_off
        data:
          entity_id: input_boolean.senseowifi_brew_normal
      - service: input_boolean.turn_off
        data:
          entity_id: input_boolean.senseowifi_brew_double

Replace "senseo-wifi-rf21" by whatever your machine is called on the MQTT broker.

Hope that helped. Please provide as much info back as you can

Post404 commented 3 years ago

This is excactly what I was looking for, thanks for that. I would have never been able to figure this out myself. But the Senseo is not responding to power switch or the 1 or 2 cups booleans. With MQTT explorer I can see that the commands are being received and the states are changing.

I might have to take the Senseo appart again to check if everything is connected right. Or could it be something software sided?

ThomDietrich commented 3 years ago

Take it one step at a time :)

  1. Use testIO.cpp to ensure everything works physically, then switch back to the normal firmware mode
  2. Observe correct state change etc on the MQTT broker (e.g. OpState should change when you turn the machine on and off) - pay attention to the "debug" MQTT topic for more details. Check this file https://github.com/ThomDietrich/SenseoWifi/blob/master/src/SenseoWifi.cpp for "setProperty" to see what's supposed to be published to MQTT when
  3. With confidence that everything works so far, try sending commands via MQTT
  4. Only after everything is working set up the connection with Home Assistant. It should work right away

With MQTT explorer I can see that the commands are being received and the states are changing.

"Are being received" is unclear to me. Check the debug topic for errors and in case of doubt check the source code to get a clearer picture of which conditions might stop execution. E.g. in order to brew coffee, a coffee mug must be present.

Post404 commented 3 years ago

I used testIO.cpp and it detected that the cup sensor is not present which is correct. Do I need to adjust something in the code for that? Also while in test mode it turned the Senseo On and Off. So at the very least the wires for that are correct. Then powering it configured and in normal mode makes it beeps twice, so it is connected to wifi and the MQTT broker. In Supervisor, Mosquitto Broker I see the senseo connection in the log as well. Then I added the MQTT integration to listen to the topics and be able to manualy publish a packet (is this the same as "send command"?) When listening to the OpState it doesn't change at all and stays on SENSEO_unknown. It should be SENSEO_NOWATER when turned on. Debug just says: brew: 19 seconds Is there something i'm missing?

Post404 commented 3 years ago

Thanks for your help! I gave it another try and got turning on and off working now from the dashboard (and Siri)! What I did to fix it was: removed the senseo config and replaced it with yours. Changed the senseo name everywhere, but without translating this time. The opState is correctly updating and everything else as well. Just the 1 cup and 2 cups switches are not working. Debug says: "no or full cup present. Not executing." I could of course add the sensor, but is there a way to disable this?

ThomDietrich commented 3 years ago

Great! Congrats! (Btw. be sure to add your voice to #42 😉 )

First of all: The cup sensor is super useful, so think about adding it. Of course, you don't have to. For that reason, I added a flag to disable the use of such a sensor. You must set/unset that flag during the initial setup (the process where you also set wifi password and MQTT credentials). Sorry, you need to reset your machine, there is no way to change the setting now.

Resetting:

My machines have the reset push button in one of the holes on the bottom of the machine. Quite useful for when you ever need to reconnect it to a new network.

Post404 commented 3 years ago

Might as well just add the sensor and the reset button. It's not that much work at this point. Thanks for helping me out and also making me understand it better!

Post404 commented 3 years ago

Oke, I added the sensor. When in test mode the number is 1024 and changed to ~60 when placing my hand in front of it. But it is also not detected in both cases, like this: Testing Cup Detector ... not detected (analog: 1024) and later: Testing Cup Detector ... not detected (analog: 59)

I connected the sensor to A0, do I also need to wire it to D0?

Post404 commented 3 years ago

I think I found it out. The sensor i ordered was a TCRT5000 without any board. After checking the versions with the board I noticed that they also have a D0 pin. I'm guessing that if I use that one it will all just work. So I ordered 2 of those for good measure. Will update when they arive.

Post404 commented 3 years ago

Received the sensor, installed the sensor and now it works perfectly!

Again, thanks for all the help!

ThomDietrich commented 3 years ago

I played around with the analog input but ended up just going with D0 for simplicity. Too bad you had to order a second time but seems like you got to a happy end. Great!!

I would leave this ticket open as I need to document Home Assistant integration in README.md. Any other details you would suggest adding?

Post404 commented 3 years ago

Now that you mention it, I remember being stuck with the question: "Where exectly do I solder de cables on the senseo board?". After comparing this: https://github.com/ThomDietrich/SenseoWifi/blob/master/images/DSC09654.jpg picture with this picture: https://github.com/ThomDietrich/SenseoWifi/blob/master/images/DSC09627.jpg I eventually got it after a while, but it would have been clearer with a picture like this: DSC09627

ThomDietrich commented 2 years ago

@Post404 as the buttons and LEDs are in the other side of the PCB, I didn't even think about marking them :D you are of course right...

ThomDietrich commented 2 years ago

Home Assistant example now in the README. You wouldn't happen to have a cooler configuration by now?

Post404 commented 2 years ago

Yes I do actually, I went full circle. I went back to visualising the Senseo in Homeassistant Lovelace.

You'll need these images in your homeassistant "www" folder: https://we.tl/t-Zrkoq89kdD It is now set up with a black senseo and a blue cup, but I could easily render different colors.

And put this code in a picture element card:

type: picture-elements
elements:
  - type: conditional
    conditions:
      - entity: binary_sensor.senseowifi_cup_available
        state: 'on'
    elements:
      - type: image
        image: /local/Senseo_kopje.png
        style:
          pointer-event: none
          transform: translate(0,0)
          top: 0
          left: 0
          right: 0
          bottom: 0
      - type: conditional
        conditions:
          - entity: sensor.senseowifi_opstate
            state: SENSEO_BREWING
        elements:
          - type: image
            image: /local/Senseo_schuim.png
            style:
              pointer-event: none
              width: 17.5%
              transform: translate(0,0)
              top: 51%
              left: 32.2%
              right: 0
              bottom: 0
              animation: schuim 25s linear 1
      - type: conditional
        conditions:
          - entity: sensor.senseowifi_opstate
            state: SENSEO_BREWING
        elements:
          - type: image
            image: /local/Senseo_stralen.png
            style:
              pointer-event: none
              transform: translate(0,0)
              top: 0
              left: 0
              right: 0
              bottom: 0
              opacity: 0
              animation: uit 25s linear 1
      - type: conditional
        conditions:
          - entity: sensor.senseowifi_opstate
            state: SENSEO_BREWING
        elements:
          - type: image
            image: /local/Senseo_schuim_voor.png
            style:
              pointer-event: none
              width: 17.5%
              transform: translate(0,0)
              top: 51%
              left: 32.2%
              right: 0
              bottom: 0
              animation: schuim 25s linear 1
      - type: image
        image: /local/Senseo_voor.png
        style:
          pointer-event: none
          transform: translate(0,0)
          top: 0
          left: 0
          right: 0
          bottom: 0
      - type: image
        image: /local/Senseo_kopje_voor.png
        style:
          pointer-event: none
          transform: translate(0,0)
          top: 0
          left: 0
          right: 0
          bottom: 0
  - type: conditional
    conditions:
      - entity: sensor.senseowifi_opstate
        state: SENSEO_READY
    elements:
      - type: image
        image: /local/Senseo_lampje.png
        style:
          pointer-event: none
          transform: translate(0,0)
          top: 0
          left: 0
          right: 0
          bottom: 0
  - type: conditional
    conditions:
      - entity: sensor.senseowifi_opstate
        state: SENSEO_HEATING
    elements:
      - type: image
        image: /local/Senseo_lampje.png
        style:
          pointer-event: none
          transform: translate(0,0)
          top: 0
          left: 0
          right: 0
          bottom: 0
          animation: my-blink 2s linear infinite
  - type: conditional
    conditions:
      - entity: sensor.senseowifi_opstate
        state: SENSEO_BREWING
    elements:
      - type: image
        image: /local/Senseo_lampje.png
        style:
          pointer-event: none
          transform: translate(0,0)
          top: 0
          left: 0
          right: 0
          bottom: 0
          animation: my-blink 2s linear infinite
  - type: conditional
    conditions:
      - entity: sensor.senseowifi_opstate
        state: SENSEO_NOWATER
    elements:
      - type: image
        image: /local/Senseo_lampje.png
        style:
          pointer-event: none
          transform: translate(0,0)
          top: 0
          left: 0
          right: 0
          bottom: 0
          animation: my-blink 0.20s linear infinite
  - type: state-icon
    entity: switch.senseowifi_power
    title: Toggle
    style:
      top: 46%
      left: 45.5%
      transform: scale(10.5,10.5)
      opacity: 0
    tap_action:
      action: call-service
      service: switch.toggle
      service_data:
        entity_id: switch.senseowifi_power
image: /local/Senseo.png
style: |

  @keyframes my-blink {
    0% { opacity: 1; }
    43% { opacity: 1; }
    50% { opacity: 0; }
    93% { opacity: 0; }
    100% { opacity: 1; }
  }
  @keyframes schuim {
    0% { top: 60%; }
    0% { width: 17%; }
    0% { left: 32.3%; }
    100% { left: 32.2%; }
    100% { width: 17.5%; }
    100% { top: 51%; }
  }
  @keyframes uit {
    0% { opacity: 1; }
    98% { opacity: 1; }
    100% { opacity: 0; }
  }

This should visualise every state even with some animation. So the cup will appear when placing it (with reflections on the senseo itself, so proud). The button light blinks correctly for every state. And when it starts brewing you see the coffee comming out and the cup starts to fill with the official Senseo coffee™. The only thing I still want to do is swap it out for a better 3D model of the Senseo.

I also added an automation in Node-red to change a light of something else depending on the state. So: heating > orange, ready > green, brewing > blinking between orange and green and when off >returning to previous state. Blnking time is assuming 1 cup, so it blinks a little short with 2 cups.

I've added comments in there so the adjustments to make it work for anybody else is a little easier but this is what I use: [{"id":"7809448eb5724189","type":"subflow","name":"Verlichting Woonkamer Check","info":"","category":"","in":[{"x":80,"y":140,"wires":[{"id":"5ab77eb286d26d9a"},{"id":"9cce0071663acf02"},{"id":"b076cebd74637606"},{"id":"cf35ec1cc6c8a262"}]}],"out":[{"x":560,"y":80,"wires":[{"id":"5ab77eb286d26d9a","port":0}]},{"x":560,"y":140,"wires":[{"id":"9cce0071663acf02","port":0}]},{"x":560,"y":200,"wires":[{"id":"b076cebd74637606","port":0}]},{"x":560,"y":260,"wires":[{"id":"cf35ec1cc6c8a262","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","status":{"x":480,"y":160,"wires":[{"id":"5ab77eb286d26d9a","port":0},{"id":"9cce0071663acf02","port":0},{"id":"b076cebd74637606","port":0},{"id":"cf35ec1cc6c8a262","port":0}]}},{"id":"5ab77eb286d26d9a","type":"api-current-state","z":"7809448eb5724189","name":"If Overdag Verlichting","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.woonkamer_fel","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"verlichting","propertyType":"msg","value":"fel","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"payload","propertyType":"msg","value":"fel","valueType":"str"}],"x":280,"y":80,"wires":[[],[]]},{"id":"9cce0071663acf02","type":"api-current-state","z":"7809448eb5724189","name":"If Avond Verlichting","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.woonkamer_aan","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"verlichting","propertyType":"msg","value":"aan","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"payload","propertyType":"msg","value":"aan","valueType":"str"}],"x":270,"y":140,"wires":[[],[]]},{"id":"b076cebd74637606","type":"api-current-state","z":"7809448eb5724189","name":"If Nacht Verlichting","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.woonkamer_dim","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"verlichting","propertyType":"msg","value":"dim","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"payload","propertyType":"msg","value":"dim","valueType":"str"}],"x":270,"y":200,"wires":[[],[]]},{"id":"cf35ec1cc6c8a262","type":"api-current-state","z":"7809448eb5724189","name":"If Uit Verlichting","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.woonkamer_licht_status","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"verlichting","propertyType":"msg","value":"uit","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"payload","propertyType":"msg","value":"uit","valueType":"str"}],"x":260,"y":260,"wires":[[],[]]},{"id":"58aca496.6ef5cc","type":"subflow","name":"Verlichting Dagdeel Check","info":"","category":"","in":[{"x":80,"y":140,"wires":[{"id":"e75ba4a2.ad6e98"},{"id":"f0b49369.709b3"},{"id":"4b6c2cb9.bab544"}]}],"out":[{"x":440,"y":40,"wires":[{"id":"e75ba4a2.ad6e98","port":0}]},{"x":540,"y":180,"wires":[{"id":"f0b49369.709b3","port":0}]},{"x":420,"y":240,"wires":[{"id":"4b6c2cb9.bab544","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","status":{"x":540,"y":120,"wires":[{"id":"e75ba4a2.ad6e98","port":0},{"id":"f0b49369.709b3","port":0},{"id":"4b6c2cb9.bab544","port":0}]}},{"id":"e75ba4a2.ad6e98","type":"api-current-state","z":"58aca496.6ef5cc","name":"If Overdag Verlichting","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.overdag_verlichting","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"verlichting","propertyType":"msg","value":"overdag","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"payload","propertyType":"msg","value":"overdag","valueType":"str"}],"x":280,"y":80,"wires":[[],[]]},{"id":"f0b49369.709b3","type":"api-current-state","z":"58aca496.6ef5cc","name":"If Avond Verlichting","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.avond_verlichting","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"verlichting","propertyType":"msg","value":"avond","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"payload","propertyType":"msg","value":"avond","valueType":"str"}],"x":270,"y":140,"wires":[[],[]]},{"id":"4b6c2cb9.bab544","type":"api-current-state","z":"58aca496.6ef5cc","name":"If Nacht Verlichting","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.nacht_verlichting","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"verlichting","propertyType":"msg","value":"nacht","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"payload","propertyType":"msg","value":"nacht","valueType":"str"}],"x":270,"y":200,"wires":[[],[]]},{"id":"e8e10213.4c003","type":"server-state-changed","z":"4f4b7a0d.954d24","name":"Senseo Status","server":"8a29b7d6.5696f8","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.senseowifi_opstate","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":200,"wires":[["b8fc5f32.c03d6"]]},{"id":"b8fc5f32.c03d6","type":"switch","z":"4f4b7a0d.954d24","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"HEATING","vt":"str"},{"t":"cont","v":"READY","vt":"str"},{"t":"cont","v":"NOWATER","vt":"str"},{"t":"cont","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":370,"y":200,"wires":[["c1835e87.e476d"],["a4de7075.b706c"],["268f92ed.ff403e"],["88b96872f25eba09"]]},{"id":"268f92ed.ff403e","type":"api-call-service","z":"4f4b7a0d.954d24","name":"Scene Blue","server":"8a29b7d6.5696f8","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.tv_meubel_blauw","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":590,"y":200,"wires":[[]]},{"id":"a4de7075.b706c","type":"api-call-service","z":"4f4b7a0d.954d24","name":"Scene Green","server":"8a29b7d6.5696f8","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.tv_meubel_groen","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":590,"y":140,"wires":[[]]},{"id":"c1835e87.e476d","type":"api-call-service","z":"4f4b7a0d.954d24","name":"Scene Orange","server":"8a29b7d6.5696f8","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.tv_meubel_oranje","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":600,"y":80,"wires":[[]]},{"id":"a8379346.67931","type":"api-call-service","z":"4f4b7a0d.954d24","name":"Scene Dim orange","server":"8a29b7d6.5696f8","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.tv_meubel_oranje_dim","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":830,"y":480,"wires":[["4610f19c.89d88"]]},{"id":"ee49e281.0be84","type":"api-call-service","z":"4f4b7a0d.954d24","name":"Scene Green","server":"8a29b7d6.5696f8","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.tv_meubel_groen","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1450,"y":480,"wires":[[]]},{"id":"65bea248.1c225c","type":"api-current-state","z":"4f4b7a0d.954d24","name":"Still Brewing?","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"SENSEO_BREWING","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.senseowifi_opstate","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":1280,"y":480,"wires":[["ee49e281.0be84"],[]]},{"id":"4610f19c.89d88","type":"stoptimer","z":"4f4b7a0d.954d24","duration":"500","units":"Millisecond","payloadtype":"num","payloadval":"0","name":"","x":1060,"y":480,"wires":[["65bea248.1c225c"],[]]},{"id":"77cb1ea9.52ee4","type":"looptimer","z":"4f4b7a0d.954d24","duration":"1","units":"Second","maxloops":"20","maxtimeout":"1","maxtimeoutunits":"Minute","name":"","x":600,"y":480,"wires":[["a8379346.67931"],["5d63ccda.131264"]]},{"id":"5d63ccda.131264","type":"stoptimer","z":"4f4b7a0d.954d24","duration":"1","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":700,"y":560,"wires":[["f9cb38bd.a219b8","33b43fb972ac1130"],[]]},{"id":"f9cb38bd.a219b8","type":"api-current-state","z":"4f4b7a0d.954d24","name":"No Water?","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"SENSEO_NOWATER","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.senseowifi_opstate","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"x":890,"y":560,"wires":[["268f92ed.ff403e"],["c1835e87.e476d"]]},{"id":"456d4ce5.d7e564","type":"trigger-state","z":"4f4b7a0d.954d24","name":"Brewing after Ready","server":"8a29b7d6.5696f8","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.senseowifi_opstate","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"SENSEO_READY","propertyValue":"old_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":160,"y":480,"wires":[["fdf43e17.1faf"],[]]},{"id":"c27d69c6.90fc18","type":"comment","z":"4f4b7a0d.954d24","name":"Senseo exception","info":"After the senseo is done \"HEATING\" it's state goes to \"BREWING\" while it should be \"READY\". De lightshow should only happen when going from \"READY\" to \"BREWING\". This is triggering when that happens.","x":150,"y":440,"wires":[]},{"id":"fdf43e17.1faf","type":"switch","z":"4f4b7a0d.954d24","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"BREWING","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":480,"wires":[["77cb1ea9.52ee4"]]},{"id":"c168d6d6f9fab442","type":"api-call-service","z":"4f4b7a0d.954d24","name":"Aanrecht Lichtstrip Aan","server":"8a29b7d6.5696f8","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.aanrecht_licht","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1250,"y":660,"wires":[[]]},{"id":"33b43fb972ac1130","type":"subflow:58aca496.6ef5cc","z":"4f4b7a0d.954d24","name":"","env":[],"x":940,"y":620,"wires":[["9d9c187fb1a50ffa","c168d6d6f9fab442"],["9d9c187fb1a50ffa","c168d6d6f9fab442"],["9d9c187fb1a50ffa","c168d6d6f9fab442"]]},{"id":"9d9c187fb1a50ffa","type":"api-call-service","z":"4f4b7a0d.954d24","name":"Scene Kamer Verlichting","server":"8a29b7d6.5696f8","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.keuken_{{verlichting}}","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1250,"y":580,"wires":[[]]},{"id":"1b6e52f596efb6ed","type":"api-current-state","z":"4f4b7a0d.954d24","name":"TV uit?","server":"8a29b7d6.5696f8","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.tv_status","state_type":"str","blockInputOverrides":false,"outputProperties":[],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":940,"y":300,"wires":[["9b1cc1bfb149da7c"],[]]},{"id":"88b96872f25eba09","type":"subflow:7809448eb5724189","z":"4f4b7a0d.954d24","name":"","env":[{"name":"kamer","value":"woonkamer","type":"str"}],"x":690,"y":300,"wires":[["1b6e52f596efb6ed"],["1b6e52f596efb6ed"],["1b6e52f596efb6ed"],["1b6e52f596efb6ed"]]},{"id":"9b1cc1bfb149da7c","type":"api-call-service","z":"4f4b7a0d.954d24","name":"Tv meubel scene","server":"8a29b7d6.5696f8","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.woonkamer_tv_meubel_{{verlichting}}","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1130,"y":300,"wires":[[]]},{"id":"a0d4e5022a306e80","type":"comment","z":"4f4b7a0d.954d24","name":"Water?","info":"This checks wether there is water after brewing.\nIf there is no water the signal goes through the upper one. If there is water then it is heating so it changes to orange.","x":1030,"y":540,"wires":[]},{"id":"d9770e942d7886f0","type":"comment","z":"4f4b7a0d.954d24","name":"Light on","info":"This is used to turn the light on in the kitchen to make sure it is on.","x":870,"y":680,"wires":[]},{"id":"e8dcd32fdcd6e868","type":"comment","z":"4f4b7a0d.954d24","name":"dimmed heating scene","info":"a dimmed variation of the scene to tone it down a little bit.","x":840,"y":440,"wires":[]},{"id":"c1298012952a66b7","type":"comment","z":"4f4b7a0d.954d24","name":"ready scene","info":"","x":1450,"y":440,"wires":[]},{"id":"6b21a1bfe6fc3f7b","type":"comment","z":"4f4b7a0d.954d24","name":"status scenes","info":"Need these scenes to correctly set the state. Replace with your own scenes","x":770,"y":140,"wires":[]},{"id":"1df3e1de77cb6b7e","type":"comment","z":"4f4b7a0d.954d24","name":"Reset light","info":"Senseo is off so this resets the status light again","x":620,"y":360,"wires":[]},{"id":"8a29b7d6.5696f8","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

ThomDietrich commented 2 years ago

That's impressive!

ThomDietrich commented 2 years ago

@Post404 I've built my own interactive lovelace controls and added a few additional entities and automations for various things. Have a look in the README.

Post404 commented 2 years ago

Thanks! I've added your UI underneath the visualisation, looks great! Also took the time to update and i'm now trying to create turn on and turn off tunes. It's fun allready, but the timing is a little bit different everytime.

Post404 commented 2 years ago

I'm now sending the tones 1 by 1 with some delay in-between creating some nice tunes. They are a little bit different every time and a delay below 200 ms doesn't always work.

It would be really cool to be able to create custom tunes and send the whole tune in 1 command and then have the Senseo playing it. The limitation then would be the amount of tones available. 😁

ThomDietrich commented 2 years ago

As you are probably aware I've added the buzzer/set topic just recently. I realized that it is very useful for integration with HA and sorts but be aware, the function is a bit fragile and difficult to use. It is non-blocking, which is a good thing. That however also means that multiple tones are not possible, as they overwrite each other and in effect you only get the last one. A blocking delay is not an option and to you would need some non-blocking routine similar to the one used to press the buttons, see here:

https://github.com/ThomDietrich/SenseoWifi/blob/27e4713f8ca2d91353af01962da620f3b44d2ee9/src/SenseoWifi.cpp#L368-L372

To be honest, I don't feel it's worth it, after all, this thing is supposed to brew coffee :D What do you think? There are probably ready-to-use libraries out there for melodies. I'm not against accepting a pull request for the feature.

Regarding the limitation of the tones: I was pragmatic here. With a few more implementation minutes you could accept an integer as the value and calculate frequency, duration, or whatever from it:

https://github.com/ThomDietrich/SenseoWifi/blob/27e4713f8ca2d91353af01962da620f3b44d2ee9/src/SenseoWifi.cpp#L143-L146

Be aware that at least my buzzer is very dependent on the frequency. Some tones are barely audible.

Also took the time to update and i'm now trying to create turn on and turn off tunes.

Let me know in case you changed anything!

It's fun already, but the timing is a little bit different everytime.

Yeah I'm afraid that won't work

Btw did you see #45

Best!

ThomDietrich commented 2 years ago

@Post404 if you want to give it a try: https://github.com/fabianoriccardi/melody-player/blob/master/examples/1_simple_play/1_simple_play.ino

Post404 commented 2 years ago

Thanks for your explanation. That make a lot of sense. The main goal was to have a clear indication off when the Senseo is turned on by an automation. That goals is achieved, everything from now on is just polish. Also most of the time the tune plays good (enough) and if not, then it still achieved the notification. At moments like this I wish I was better at coding. I'll still have a look at what you send after and see what I can do.

I really had fun with making the tunes so far. At this point I'm so invested in this project and the level off overkill features is already so high that this doesn't stand out that much . And it has a high WAF, I don't even drink coffee myself.

ThomDietrich commented 2 years ago

I don't even drink coffee myself.

Haha nice :) Happy you enjoyed this! Please play around with tunes, who knows, maybe we can include them! I'll close this ticket but please open a new one to discuss tunes :)