Pilight, KaKu switch, switch state?

All nice and running kaku switches from new kaku are running perfectly, but there is no option to read state of the switch.
And I know for sure that pilight sends them cause in other android apps, I see the state switch to on when i set them in pilight, so why not in HA or am I missing something?

It is a little difficult for me to understand your issue :wink:. 433 devices do usually not promote their state, reading of the state is not possible, it is a unidirectional communication. What I think you mean is that the state in hass should change if you use your remote? Or what do you mean with state change and other apps?

Hi David, sorry for confusing you.

I use a raspberry pi 3 to send the 433mHz signal and for receiving signals, (think a handset or a wallswitch that transmits the on/off signal or dim for new KaKu/CoCo signals).
So it works as a transeiver, the actual lamp is sometimes when build in a wall (concrete walls here) a bit of hit and miss so this is as you state so correctly the lamp doesn’t send anything back to what it is doing … hopefully on and off.

On my Raspberry I have a program/python named Pilight when it receives a signal from say wall switch, pir sensor or handset, it decodes it and send a json out to the net saying switch is toggled, and that signal is what i want to use in HA to see hey a switch is set, else the switch stays greyed out in HA and the light is on/triggered, plus when I want to switch it off from HA first pretend the light is on so switch on and switch off is needed.

A lot of words but do I make sense now or is it worse now ?

You can reduce the not switching probability to almost 0% by sending the code repeatedly. The following should work:.

switch:
- platform: pilight
  switches:
    light:
      on_code:
        protocol: intertechno_old
        unit: 3
        id: 4
        'on': 1
        repeat: 10
      off_code:
        protocol: intertechno_old
        unit: 3
        id: 4
        'off': 1
        repeat: 10

Do you mean the python module hosted on pypi called pilight? Or something else?

This is how it is implemented already. Just define in your pilight switch config a on_code_receive and off_code_receive. If these codes are received the state will be changed. If your on_code_receive matches the on_code please also set the new echo option, to prevent hass to resent a code that toggled your hardware already (see here).

Thanks David!

I didn’t mention but with the new_kaku protocol I use a repeat, with the old you can’t always do this cause dimmers start dimming up and down when you send a repeat, your house starts to look like an old fashioned disco that way, :wink:

Yes that is the programm I am using and thanks for the new info given in your link!

Yes :smiley: For dimmers this is not something you want. At least not always :wink:
Since you are the first I know having a dimmer: Is it possible to dim to a fixed value or is the only way to hold and press the on button for some time? If dimming to a fixed value is possible a pilight light component would be useful in hass.

There is a pilight protocol, but untill now I haven’t found the way to set the dimmer with a slider, working on it. my code is

  Plafond:
    on_code:
      protocol: kaku_dimmer
      id: 65166612
      unit: 0
      'on': 1
      'dimlevel-minimum': 0
      'dimlevel-maximum': 15
    off_code:
      protocol: kaku_dimmer
      id: 65166612
      unit: 0
      'off': 1
      'dimlevel-minimum': 0
      'dimlevel-maximum': 15

And this works without the dimming, dimming is same as the old kaku protocol fast switch a lighton-off-on and it starts dimming up and down at the desired level you switch the light off and on again and then it retains that level, even after switching off.

In the gui from pilight dimmers are a seprate tab with full the possiblity to set a level even before switching on and it will start at that level. Thus it must be possible!

I found that your dimmer could understand the following: dimlevel: value. Can you do this for testing:

on_code:
      protocol: kaku_dimmer
      id: 65166612
      unit: 0
      'on': 1
      dimlevel: 3
off_code:
      protocol: kaku_dimmer
      id: 65166612
      unit: 0
      'off': 1

and check if the device does actually turn on in a dimmed state? That would be awesome.

I’ll give it a go wait please!

By the by I am trying to port things to an esp much more compact and easier to hang sensors on I did it wit espeasy which is a nice piece of programming. and everything works via mqtt, but allas not the kaku switch so now I try via command line and guess what, I miss a huge part of brain, cause getting all kind of errors from my automation.yaml. Maybe maybe, might I trouble you some day with it cause I am running into a wall.

OK David, spot on that works! dimlevel no prob!

Good to know. I will implement a light component that enables to dim lights in hass when i find time.

That would be great, please notify me if you succeeded!

At this moment I am trying to bind it to a slider, but I am lacking serious knowhow, and maybe even braincells.

For whats worth it, I am dealing with the same issue.
I would love to see the switch with working dimmer functionality in combination with pilight.
For now I’ll use the fixed dimlevel.

Here’s how I did it…

from input_sliders.yaml

lrceilingbrightness_slider:
  name: lrcbrightness
  initial: 6
  min: 0
  max: 15
  step: 1

From switches.yaml

- platform: command_line
  switches:
    pilivingroomceilingdimmer:
      command_on:  pilight-send -S ip -P port -p kaku_dimmer     -t -i 2 -u 15   
      command_off: pilight-send -S ip -P port -p kaku_dimmer     -f -i 2 -u 15    

from shellcommand.yaml

set_lrclamp_to_slider: '/usr/local/bin/pilight-send -p kaku_dimmer -t -u 15 -i 2 -d {{ states.input_slider.lrceilingbrightness_slider.state }} -S ip -P port'

From automation.yaml

 - alias: 'Dim Livingroom Ceiling Light'
   trigger:
     - platform: state
       entity_id: input_slider.lrceilingbrightness_slider
   action:
     - service: shell_command.set_lrclamp_to_slider
       
 - alias: 'Dim Livingroom Ceiling Light by Switch'
   trigger:
     - platform: state
       entity_id: switch.pilivingroomceilingdimmer
       to: 'on'
   action:
     - service: shell_command.set_lrclamp_to_slider

Hope that helps :slight_smile:

Hi Keith,

That’s interesting, I tried it from sliders and I didn’t get it working, someone said he’ll help but never heard of him again.
Nevertheless what I found out is that pilight does understand dimlevel.
Setting a dimlevel is possible I only couldn’t get it running in a slider, but this is what I tried.

in Switches:

    Plafond:
        on_code:
            protocol: kaku_dimmer
            id: 65166612
            unit: 0
            'on': 1
        #   dimlevel: 7
            dimlevel-minimum: 0
            dimlevel-maximum: 15

I commented dimlevel but it works!
But the translation to slider didn’t.

Maybe you can make something out of it, and meanwhile I try your method, thanks.

Tnx a lot! I’ll try your solution!

If you like these are my tries:

Switches.yaml—

Pilight

  • platform: pilight
    switches:
    Plafond:
    on_code:
    protocol: kaku_dimmer
    id: 65166612
    unit: 0
    ‘on’: 1
    # dimlevel: 7
    dimlevel-minimum: 0
    dimlevel-maximum: 15
    off_code:
    protocol: kaku_dimmer
    id: 65166612
    unit: 0
    ‘off’: 1
    # dimlevel: 7
    dimlevel-minimum: 0
    dimlevel-maximum: 15

sliders.yaml

dim_plafond:
name: Dim niveau
initial: 7
min: 0
max: 15
step: 1

automations.yaml

I use my wall lamp, cause I deleted the plafond lamp (ceiling) but it was the same.

  • alias: set_muurspot
    trigger:

    • platform: state
      entity_id: input_slider.dim_muur
      action:
    • service: light.turn_on
      data_template:
      entity_id: switch.muur
      dimlevel: ‘{{ trigger.to_state.state | int }}’
  • alias: set_muur_slider
    trigger:

    • platform: state
      entity_id: input_slider.dim_muur
      action:
    • service: input_slider.select_value
      data_template:
      entity_id: input_slider.dim_muur
      value: ‘{{ states.switch.muur.attributes.dimlevel }}’

shell_commands.yaml

set_lamp_to_slider: ‘dimlevel: {{ states.input_slider.dim_muur.state }}’

That is what I recovered, because I ended this try. I rested on just on off.

I’ve given up with the pilight HA platform as for me it’s completely unreliable and I just use pilight-send to control my switches/lights which pretty much always works.

Hi Keith,

Mine are fairly cooperative, e few times they miss, but that is inherent to 433mHz KaKu switches specially the ones build in the wall are missing a command sometimes no matter hwo I address these.

But please can you explain all the parameters in the line:

command_on: pilight-send -S ip -P port -p kaku_dimmer -t -i 2 -u 15

I don’t know how to interpret these. -S, -P, -p, -t, -i, -u, I understand a few of them but please eleborate on them?