• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Switch without a state
#1
Question 
Hi, I just started using pilight. Hardware setup, installation, getting started, everything worked fine and I'm able to control my kaku and Elro-lights.

But, next step is to set a 'theme'. So for instance, I'd describe these themes:
  • All lights full on
  • Living room on, kitchen off
  • Dinner theme
  • Working
  • Cosy low light
  • Welcome light

I am using this kaku-transmitter (AWST-8802):
[Image: 92c090e788d98cc42c1dc6a785481c91.png]

And, I don't want to use this as "2 switches", but as "4 input buttons".

Rotate themes
My goal is to rotate through these themes when pressing one buttons many times. So, for instance, when pressing the 'off-side' of the switch, my lights go to "all lights full on", "living room on", "dinner theme", etc.

In pilight I can use this transmitter, but it only gives me two switches with a fixed state. When building rules to make my scenes happen, it doesn't register a new event, when the switch is already in a certain state.

Neutral?
Perhaps the best way to fix this is to be able to work with incoming signals, so my switch-off signal is just incoming, that can be used without changing a state. Or, I can build a rule to reset a switch to neutral after setting my theme. That way pressing one side of my wall-switch will:
  • Switch to 'off'
  • Have a rule to do stuff
  • Reset itself from 'off' to 'neutral' again.

I'd love to hear your thoughts on this.
 
Reply
#2
I would use several generic switches for each theme. Then loop through them like this:
Code:
IF wallswitch.state IS on OR wallswitch.state IS off AND allTheme.state IS on AND livingTheme.state IS off AND dinnerTheme.state IS off THEN switch DEVICE livingTheme TO on AND switch DEVICE allTheme TO off
IF wallswitch.state IS on OR wallswitch.state IS off AND allTheme.state IS off AND livingTheme.state IS on AND dinnerTheme.state IS off THEN switch DEVICE dinnerTheme TO on AND switch DEVICE livingTheme TO off
etc.
 
Reply
#3
Thnx for your input Curlymo! I wasn't aware of the fact that conditions could be combined AND actions could be combined.

Config error
Even so, your suggestion is not working, it gives the error "[Apr 27 15:28:32:315317] pilight-daemon: ERROR: switch actions are formatted as "switch DEVICE ... TO ..."".

This is my full config.json file, to try out your suggestion:

Code:
{
    "devices": {
        "wallswitch": {
            "protocol": [ "kaku_switch" ],
            "id": [{
                "id": 9120400,
                "unit": 11
            }],
            "state": "off"
        },
        "allTheme": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 100
            }],
            "state": "on"
        },
        "livingTheme": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 100
            }],
            "state": "off"
        },
        "dinnerTheme": {
            "protocol": [ "generic_switch" ],
            "id": [{
                "id": 100
            }],
            "state": "off"
        }
    },
    "rules": {
        "lightswitch": {
            "rule": "IF wallswitch.state IS on OR wallswitch.state IS off AND allTheme.state IS on AND livingTheme.state IS off AND dinnerTheme.state IS off THEN switch DEVICE livingTheme TO on AND switch DEVICE allTheme TO off",
            "active": 1
        },
        "lightswitch2": {
            "rule": "IF wallswitch.state IS on OR wallswitch.state IS off AND allTheme.state IS off AND livingTheme.state IS on AND dinnerTheme.state IS off THEN switch DEVICE dinnerTheme TO on AND switch DEVICE livingTheme TO off",
            "active": 1
        }
    },
    "gui": {
        "dinnerTheme": {
            "name": "Dinner",
            "group": [ "Lamps" ],
            "media": [ "all" ]
        },
        "livingTheme": {
            "name": "livingTheme",
            "group": [ "Lamps" ],
            "media": [ "all" ]
        },
        "allTheme": {
            "name": "allTheme",
            "group": [ "Lamps" ],
            "media": [ "all" ]
        },
        "wallswitch": {
            "name": "allTheme",
            "group": [ "Lamps" ],
            "media": [ "all" ]
        }
    },
    "settings": {
        "log-level": 4,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "send-repeats": 10,
        "receive-repeats": 1,
        "webserver-enable": 1,
        "webserver-root": "/usr/local/share/pilight/",
        "webserver-port": 5001,
        "webserver-cache": 1,
        "firmware-update": 0
    },
    "hardware": {
        "433gpio": {
            "sender": 0,
            "receiver": 1
        }
    },
    "registry": {
        "pilight": {
            "firmware": {
                "version": 3,
                "lpf": 80,
                "hpf": 16000
            },
            "version": {
                "current": "6.0"
            }
        }
    }
}

Toggle with one side only?
Furthermore, in this setup it seems I have to use both 'on' and 'off' sides of my wall switch to rotate my themes. Because a rule is only triggered when changing a state right? So, when my wall switch is in 'off', it won't execute a new rule when re-applying 'off', I assume.

I just want to be able to use the four ends of my wall switch for different purposes:
Switch left ON: All my devices full on
Switch left OFF: All my devices off
Switch right ON: Rotate themes
Switch right OFF: My home in 'away mode'
 
Reply
#4
1. You need the latest nightly for my suggestion.
2. Your assumption is correct.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Sunset state check parse error dennisvo 7 463 1 hour ago
Last Post: janaobst
  skipping overridden action switch do1eh 2 683 01-19-2019, 05:25 PM
Last Post: do1eh
  Can't switch Relay device by rules: Error switch.lua:77 wobbi 6 1,071 07-31-2018, 06:25 AM
Last Post: curlymo
  Program can't be set to state running Gisto 7 1,280 07-17-2018, 12:51 PM
Last Post: Gisto
  Send on command when switch is already "on" joshovki 1 626 01-28-2018, 11:27 PM
Last Post: curlymo
  Always trigger event on any device state Phil 8 2,408 03-22-2017, 07:30 PM
Last Post: Phil
  Problem with a Rule for a One Button Switch martin-dj 1 1,342 03-06-2017, 12:01 PM
Last Post: pilino1234
  duration switch protocol creamers 6 2,520 01-10-2017, 10:04 PM
Last Post: wo_rasp
  action: switch Niek 54 20,900 03-31-2016, 06:24 PM
Last Post: jjj
  [Solved] Trying to switch my light using datetime manmetdehamer 2 2,388 11-25-2015, 01:33 PM
Last Post: manmetdehamer

Forum Jump:


Browsing: 1 Guest(s)